3

最多 iOS 9 闪光灯开/关/自动工作正常。但在 iOS 10 中,flash 无法正常工作。

    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];

并以编程方式更改闪存模式。

 [self.camObj setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
4

5 回答 5

2

这是 iOS 10 的一个错误(至少从 10.0.2 开始)。请注意,如果打开,设置cameraFlashMode 确实有效。showsCameraControls

于 2016-10-19T16:41:21.180 回答
2

在 iOS 10.2上解决的问题。现在手动相机闪光模式处理再次正常工作,无需启用和禁用showsCameraControls。

于 2016-12-14T09:26:28.983 回答
1

这是一个 iOS 10 的 bug,所以你需要继承 UIImagePickerController 并覆盖 cameraFlashMode 设置器:

 - (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;
     }
 }
于 2016-10-24T12:28:28.907 回答
0

有报道称,第三方更换部件可能会导致这些症状,尤其是有关手机需要冷却和相机/闪光灯无法工作的消息。手机上的固件也可能会检查内置部件是否为正品,如果检测到非 Apple 硬件,这也可能导致这些问题。

于 2016-10-04T08:55:50.237 回答
0

对于 iOS 10,尝试先渲染 UIImagePickerController 并再次设置相机闪光灯。尝试

[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];
    }
}];

希望这会有所帮助。

于 2016-10-28T20:05:41.117 回答