判断是否允许使用相机
来源:互联网 发布:程序员的心理疾病 编辑:程序博客网 时间:2024/05/23 11:24
注意:此方法只对ios7以上的系统有用,刚才用“我查查”试了下,如果是在ios6的系统的话就直接崩溃了,况且ios6上也没有“设置--隐私--相机” 那一项
if(IOS7) { AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; if (authStatus == AVAuthorizationStatusNotDetermined) { [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { if(granted){ UIImagePickerController *pickerController = [[UIImagePickerController alloc] init]; pickerController.delegate = self; pickerController.sourceType = UIImagePickerControllerSourceTypeCamera; pickerController.allowsEditing = NO; [self presentViewController:pickerController animated:YES completion:^{ }]; } else { return; } }]; } else if (authStatus == AVAuthorizationStatusDenied) { UIAlertView* alert = [[UIAlertView alloc] initWithTitle: nil message:@"请在iPhone的\"设置-隐私-相机\"选项中,允许xx访问你的相机。" delegate:nil cancelButtonTitle: @"确定" otherButtonTitles:nil, nil]; [alert show]; } else if (authStatus == AVAuthorizationStatusAuthorized) { UIImagePickerController *pickerController = [[UIImagePickerController alloc] init]; pickerController.delegate = self; pickerController.sourceType = UIImagePickerControllerSourceTypeCamera; pickerController.allowsEditing = NO; [self presentViewController:pickerController animated:YES completion:^{ }]; } else if (authStatus == AVAuthorizationStatusRestricted) { UIAlertView* alert = [[UIAlertView alloc] initWithTitle: nil message:@"请在iPhone的\"设置-隐私-相机\"选项中,允许xx访问你的相机。" delegate:nil cancelButtonTitle: @"确定" otherButtonTitles:nil, nil]; [alert show]; } } else { UIImagePickerController *pickerController = [[UIImagePickerController alloc] init]; pickerController.delegate = self; pickerController.sourceType = UIImagePickerControllerSourceTypeCamera; pickerController.allowsEditing = NO; [self presentViewController:pickerController animated:YES completion:^{ }]; }
0 0
- 判断是否允许使用相机
- 判断是否允许使用相机
- iOS 判断相机权限是否被限制,判断相机是否可以使用
- iOS 判断相机权限是否被限制,判断相机是否可以使用
- iOS 判断相机权限是否被限制,判断相机是否可以使用
- iOS 判断应用是否有使用相机的权限
- android判断service是否允许
- JavaScrip判断是否允许弹出窗口
- IOS 判断相册是否允许访问
- 如何判断应用是否允许开启定位
- iOS 判断是否允许app消息推送
- 判断应用是否允许定位当前位置
- 判断手机app是否允许定位
- 判断用户是否允许通知消息
- 判断新增行是否允许修改
- IOS7判断程序是否可用相机
- iOS判断设备的相机是否可用
- android判断设备是否有相机
- 第一次尝试Crack(逆向异或算法)
- 迫不及待的想要分享一个神器Codota
- oc初始化方法,便利构造器
- Linux中nginx
- PHP5 non-thread-safe和thread-safe的区别
- 判断是否允许使用相机
- Android 深入理解Android中的自定义属性
- Java之美[从菜鸟到高手演变]之设计模式四
- Java8 Collection接口源码阅读(二)
- 数据结构实验之队列一:排队买饭
- Android 之 Services
- LIBSVM工具箱的安装与使用
- A Knight's Journey(DFS)深搜
- Android之开启新的activity并获取返回值