3

Up to iOS 9 flash on / off / auto working fine. But in iOS 10 flash is not working.

    self.camObj = [[UIImagePickerController alloc] init];

    [self addCameraToTheScreen];
    NSArray *mediaTypes = [NSArray arrayWithObject:(NSString*)kUTTypeMovie];
    self.camObj.mediaTypes = mediaTypes ;
    self.camObj.modalTransitionStyle = UIModalPresentationFullScreen;
    self.camObj.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.camObj.videoMaximumDuration = 10.0f;
    self.camObj.showsCameraControls = NO;
    self.camOptionsView.frame = [UIScreen mainScreen].bounds;
    self.camObj.delegate = (id<UIImagePickerControllerDelegate,UINavigationControllerDelegate>)self;
    [self.camObj setCameraOverlayView:self.camOptionsView];

and programmatically changing flash mode.

 [self.camObj setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
Cœur
  • 37,241
  • 25
  • 195
  • 267
Thukaram
  • 1,085
  • 2
  • 13
  • 33
  • 1
    I'm seeing this too. Haven't found a workaround yet. As long as I leave it set to its default mode of Auto, the flash works as expected. When I try to switch the mode to On, the mode actually switches to Off. From this point forward it remains Off, even if I try switching it back to Auto. – cduhn Oct 05 '16 at 02:49
  • 2
    To everyone experiencing this issue, please submit a bug report to put it on Apple's radar (so to speak). https://bugreport.apple.com/ – cduhn Oct 05 '16 at 03:22
  • This is fixed in 10.2 beta 1. Just tried it out. – DDRBoxman Nov 01 '16 at 19:43

5 Answers5

2

This is a bug with iOS 10 (as of 10.0.2, at least). Note that setting cameraFlashMode does work if showsCameraControls is turned on.

coco
  • 2,998
  • 1
  • 35
  • 58
2

Issue solved on iOS 10.2 . Now manual camera flash mode handling works fine again, without need of enabling and disabling showsCameraControls.

dejix
  • 1,144
  • 1
  • 12
  • 23
1

It's an iOS 10 bug, so you need to inherit from UIImagePickerController and override cameraFlashMode setter:

 - (void)setCameraFlashMode:(UIImagePickerControllerCameraFlashMode)cameraFlashMode {
     if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10 && !self.showsCameraControls) {
         self.showsCameraControls = YES;
         super.cameraFlashMode = cameraFlashMode;
         self.showsCameraControls = NO;
     } else {
         super.cameraFlashMode = cameraFlashMode;
     }
 }
0

There have been reports that 3rd party replacement parts can cause these symptoms, especially the message about the phone needing to cool down and the camera / flash not working. The firmware on the phone might also check the built in parts to be genuine, which can also lead to those issues, if non Apple hardware is being detected.

0

For iOS 10, try to render UIImagePickerController first and set the camera flash again. Try

[self presentViewController:self.camObj animated:YES completion:^{
    //For iOS 10 and higher versions so it can set the proper flashmode
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10) {
       [self.camObj setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
    }
}];

Hope this could help.