如何知道该应用程序在iOS8中具有摄像头访问权限或不能以编程方式

我的应用程序使用相机.
在iOS8中,他们包括一个新的隐私设置,相机,用户可以管理的位置
对每个应用程序使用摄像机权限.

问题:
如果用户不允许我的应用程序使用相机,那么我如何才能知道
我的应用程序无法访问相机.
像我可以使用ALAssetsLibrary authorizationStatus来发现照片库的状态
或ABAddressBookGetAuthorizationStatus来了解电话簿访问状态.

题:
在iOS8中我如何知道我的应用程序是否具有相机访问权限,
这样我可以提示用户允许相机访问我的应用程序?

我有下面打印屏幕的照片摊位有同样的问题
作为我的应用程序.

当没有相机访问时,它只会显示黑屏无信息.

解决方法

检查 AVAuthorizationStatus摄像机的可用性,然后处理案件
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(status == AVAuthorizationStatusAuthorized) {
  // authorized
} else if(status == AVAuthorizationStatusDenied){
  // denied
} else if(status == AVAuthorizationStatusRestricted){
  // restricted
} else if(status == AVAuthorizationStatusNotDetermined){
  // not determined
  [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
    if(granted){
  NSLog(@"Granted access");
} else {
  NSLog(@"Not granted access");
}
  }];
}

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...