如何知道应用程序有摄像头访问或在iOS8中没有程序 [英] How to know that application have camera access or not programmatically in iOS8
问题描述
我的应用程序使用相机。
在iOS8中,他们包括一个新的隐私设置,相机
,其中用户可以管理
使用相机的权利应用程序。
My application uses the camera.
In iOS8 they include a new privacy setting, Camera
, where the user can manage
use of camera rights for each application.
问题:
如果用户不允许我的应用程序使用摄像头,
我的应用程序没有摄像头的访问权限。
像我可以使用 ALAssetsLibrary authorizationStatus
来发现照片库的状态
或 ABAddressBookGetAuthorizationStatus
以了解电话簿访问的状态。
Problem:
If the user didn't allow my application to use camera then how can i know that
My application have no access for camera.
like i can use ALAssetsLibrary authorizationStatus
to discover the status of the photolibrary
or ABAddressBookGetAuthorizationStatus
to know status of phonebook access.
/ strong>
我如何知道我的应用程序在iOS8中是否具有相机访问权限,
,以便我可以提示用户允许相机访问我的应用程序?
Question:
How i can know whether my application has camera access or not in iOS8,
so that I may prompt the user to allow camera access for my application?
我在下面的照片展位的打印屏幕有相同的问题
作为我的应用程序。
I have below print screen of Photo booth which having same problem as my application have.
>
When there is no camera access it will only show black screen no message nothing.
推荐答案
检查 AVAuthorizationStatus ,然后处理相应的情况
Check AVAuthorizationStatus for camera availability and then handle cases accordingly
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");
}
}];
}
这篇关于如何知道应用程序有摄像头访问或在iOS8中没有程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!