iOS 9闪存开启/关闭/自动正常工作。但是在iOS 10中闪存不起作用。
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];
答案 0 :(得分:2)
这是iOS 10的一个错误(至少10.0.2)。请注意,如果cameraFlashMode
处于启用状态,则设置showsCameraControls
会有效。
答案 1 :(得分:2)
在iOS 10.2 上解决了问题。 现在手动相机闪光模式处理再次正常工作,无需启用和禁用showsCameraControls。
答案 2 :(得分:1)
这是一个iOS 10的bug,所以你需要从UIImagePickerController继承并覆盖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;
}
}
答案 3 :(得分:0)
有报告称第三方更换部件可能会导致这些症状,尤其是有关phone needing to cool down and the camera / flash not working的消息。 如果检测到非Apple硬件,手机上的固件也可能会检查内置部件是否为正品,这也可能导致这些问题。
答案 4 :(得分: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];
}
}];
希望这可以提供帮助。