您的位置:首页 > 移动开发 > IOS开发

ios7及以后系统关于新增相机对应用的隐私授权判断问题

2014-10-11 19:45 423 查看
问题来源: ios7及以后的系统自带二维码扫描库AVFoundation,但是若关闭相机对应用的隐私授权后,二维码扫描会造成应用闪退;

此时,需针对用户是否开相机隐私授权做相关判断;

[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];

 

[UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear];

以上两个方法均无法实现判断,返回值均为yes,只能作为iPhone/ipod 是否有相机功能判断;

具体解决方法如下:

if(isIOS7Later)   //isIOS7Later 是用来区分ios7及以后的系统;
    {
        AVAuthorizationStatus authStatus = [AVCaptureDevice
authorizationStatusForMediaType:AVMediaTypeVideo];
        if (authStatus !=
AVAuthorizationStatusAuthorized)
        {
//此处可以做相关提示及操作;
            UIAlertView * tip = [[UIAlertView
alloc] initWithTitle:@"温馨提示"
message:@"您相机隐私授权尚未打开,若要打开请前往
设置-隐私-相机
中打开。"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"确定",
nil];
            [tip show];
            [tip release];
            return;
        }
    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios7 二维码 隐私
相关文章推荐