[code]相机访问权限
2016-07-05 本文已影响25人
回_望
相机访问权限
+(BOOL)hasAcessRightAboutPhoto;{
__weak typeof(self) weakSelf = self;
NSString *mediaType = AVMediaTypeVideo;
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied){
//处理未授权的业务逻辑
return NO;
}else if (authStatus ==AVAuthorizationStatusNotDetermined{
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if (granted){
//根据是否授权做不同的业务逻辑处理
}
}];
}else if (authStatus == AVAuthorizationStatusAuthorized){
//处理已经授权的业务逻辑
}
return YES;
}