热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在iOS10中设置相机闪光灯不起作用-SettingcameraflashnotworkinginiOS10

CannotsetthecameraflashproperlyforiOSversions10andabove(thisisworkingcorrectlyiniOS

Cannot set the camera flash properly for iOS versions 10 and above (this is working correctly in iOS 9). It always defaults to UIImagePickerControllerCameraFlashModeAuto.

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

Here's my code:

这是我的代码:

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

1 个解决方案

#1


2  

So I guess I have to wait for the UIImagePickerController to be rendered and set the camera flash again.

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

So I updated

所以我更新了

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

to

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

Hope this could help.

希望这可以帮助。


推荐阅读
author-avatar
李林1108_965
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有