• 获取当前相机的权限


       if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
        {
            //获取当前的授权状态
            AVAuthorizationStatus AVStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
            
            //只要没有拒绝
            if (AVStatus != AVAuthorizationStatusDenied) {
                UIImagePickerController *pickerVc = [[UIImagePickerController alloc] init];
                pickerVc.delegate = self;
                //设置拍照后的图片可被编辑
                pickerVc.allowsEditing = YES;
                pickerVc.sourceType = UIImagePickerControllerSourceTypeCamera;
                _pickerVc = pickerVc;
                [self presentViewController:pickerVc animated:YES completion:nil];
            }else{

        //如果已经拒绝

        //弹出提示框
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"请在iPhone的“设置-隐私-相机”选项中,允许***访问你的相机" message:nil preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *photoesAction = [UIAlertAction actionWithTitle:@"好" style:0 handler:^(UIAlertAction * _Nonnull action) {
                }];
                [alertController addAction:photoesAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
            
        }else
        {
            BCJLog(@"模拟器无法打开照相机,请在真机中使用");
        }

  • 相关阅读:
    26 转义符 re模块 方法 random模块 collection模块的Counter方法
    25 正则表达式
    24 from 模块 import 名字
    24 from 模块 import 名字
    24 from 模块 import 名字
    23 析构方法 items系列 hash方法 eq方法
    21 isinstance issubclass 反射 _str_ _new_ _len_ _call_
    20 属性, 类方法, 静态方法. python2与python3的区别.
    python(1)
    python之字符串格式化
  • 原文地址:https://www.cnblogs.com/LiRenee/p/5379855.html
Copyright © 2020-2023  润新知