判断相机权限

#pragma mark - 相机权限
-(BOOL)camaraEnable;
{
    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    
    if (authStatus == AVAuthorizationStatusDenied) {
        
        if (IOS8_OR_LATER) {
            
            UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"相机被禁用"
                                                          message:@"请在iPhone的“设置-隐私-相机”中允许**访问您的相机。"
                                                         delegate:self
                                                cancelButtonTitle:@"取消"
                                                otherButtonTitles:@"设置", nil];
            alert.tag = 800;
            
            [alert show];
            
        } else {
            
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"相机被禁用"
                                                           message:@"请在iPhone的“设置-隐私-相机”中允许**访问您的相机。"
                                                          delegate:nil
                                                 cancelButtonTitle:@"确定"
                                                 otherButtonTitles:nil, nil];
            [alert show];
        }
        
        return NO;
        
    } else {
        
        //允许了
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            
            return YES;
            
        } else {
            
            MyNSLog("设备不支持摄像头");
            
            return NO;
        }
    }
}

你可能感兴趣的:(判断相机权限)