设置相机闪光灯在iOS 10中不工作



iOS 10及以上版本无法正确设置相机闪光灯(这在iOS 9中正常工作)。它总是默认为UIImagePickerControllerCameraFlashModeAuto.

下面是我的代码:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
[picker setAllowsEditing:NO];
[picker setDelegate:self];
[picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[picker setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
[picker setCameraOverlayView:overlayView];
[self presentViewController:picker animated:YES completion:Nil];

所以我想我必须等待UIImagePickerController被渲染并再次设置相机闪光灯。

所以我更新了

[self presentViewController:picker animated:YES completion:nil];

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

希望这能帮到你。

相关内容

  • 没有找到相关文章

最新更新