【问题标题】:Setting camera flash not working in iOS 10设置相机闪光灯在 iOS 10 中不起作用
【发布时间】:2016-10-28 19:30:35
【问题描述】:

无法为 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];

【问题讨论】:

  • 你检查的是前置摄像头还是后置摄像头?
  • 我正在检查后置摄像头。

标签: ios objective-c camera ios10 camera-flash


【解决方案1】:

所以我想我必须等待 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];
    }
}];

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多