[code]相机访问权限

相机访问权限

+(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;
}

你可能感兴趣的:([code]相机访问权限)