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

NSString * mediaType = AVMediaTypeVideo;

    AVAuthorizationStatus  authorizationStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];

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

        UIAlertController * alertC = [UIAlertController alertControllerWithTitle:@”摄像头访问受限 message:nil preferredStyle:UIAlertControllerStyleAlert];

        [self presentViewController:alertC animated:YES completion:nil];

        UIAlertAction * action = [UIAlertAction actionWithTitle:@”取消 style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {

            [self dismissViewControllerAnimated:YES completion:nil];

        }];

        [alertC addAction:action];

    }else{

}

发布日期:
分类:iOS

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据