iOS如何判断应用是否开启摄像头权限

NSString * mediaType = AVMediaTypeVideo;

    AVAuthorizationStatus  authorizationStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];

    if (authorizationStatus == AVAuthorizationStatusRestricted|| authorizationStatus == AVAuthorizationStatusDenied) {

        UIAlertController * alertC = [UIAlertControlleralertControllerWithTitle:@"摄像头访问受限" message:nilpreferredStyle:UIAlertControllerStyleAlert];

        [self presentViewController:alertC animated:YEScompletion:nil];

        UIAlertAction * action = [UIAlertActionactionWithTitle:@"取消" style:UIAlertActionStyleCancelhandler:^(UIAlertAction *action) {

            [self dismissViewControllerAnimated:YEScompletion:nil];

        }];

        [alertC addAction:action];

    }else{

}

你可能感兴趣的:(ios,摄像头)