相册权限

(只需要判断是否为ALAuthorizationStatusDenied即可)
typedef NS_ENUM(NSInteger, ALAuthorizationStatus) {
ALAuthorizationStatusNotDetermined = 0, 用户尚未做出了选择这个应用程序的问候
ALAuthorizationStatusRestricted, 此应用程序没有被授权访问的照片数据。可能是家长控制权限。
ALAuthorizationStatusDenied, 用户已经明确否认了这一照片数据的应用程序访问.
ALAuthorizationStatusAuthorized 用户已授权应用访问照片数据.
}
2.访问相机时,优先访问相册,可以理解为相机为相册的子功能。
3.关于IOS8之后新跳转方法:UIApplicationOpenSettingsURLString,这个跳转方法可以直接跳转到设置中的项目设置页面的方法,其中的允许“xxx”访问中的项目不是自己添加的,而是系统自动识别的,每请求一次这个权限时,系统会自动记录并添加!!!
4.block作为参数传递:

  • (void)test:(返回值类型(^)(参数1,参数2))参数名; // 参数名称可省略
    -(void)calculate:(int(^)(int))calculateBlock;
## 弹出对话框,进行选择
- (void)handleTakePicture {__weak typeof(self) weakSelf = self;UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {[weakSelf openCamera];}];UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"从相机选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {[weakSelf openAlbum];}];UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];[alert addAction:action1];[alert addAction:action2];[alert addAction:action3];[self.targetVC presentViewController:alert animated:YES completion:nil];
}## 操作
2.1 打开相机
- (void)openCamera {// 打开相机[self checkAuthorizateCameraWithBlock:^(BOOL cameraAuthSuccess, BOOL albumAuthSuccess) {if(!albumAuthSuccess) {//            [GTAppUtils showAlertViewWithTitle:@"" message:@"请到 设置》隐私》相册 开启相册权限."];UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"相册未授权" message:@"授权xxx访问你的照片" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];[[UIApplication sharedApplication] openURL:url];}];UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}];[alertVC addAction:action1];[alertVC addAction:action2];[self.targetVC presentViewController:alertVC animated:YES completion:nil];return;}if(cameraAuthSuccess) {if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {// 手机支持相机拍摄的情况下执行下列代码UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;imagePicker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;imagePicker.mediaTypes = @[(NSString *)kUTTypeImage];imagePicker.delegate = self;imagePicker.allowsEditing = YES;[self.targetVC presentViewController:imagePicker animated:YES completion:nil];NSLog(@"---");}} else {UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"相机未授权" message:@"授权xxx访问你的照片" preferredStyle:UIAlertControllerStyleAlert];UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];[[UIApplication sharedApplication] openURL:url];}];UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}];[alertVC addAction:action1];[alertVC addAction:action2];[self.targetVC presentViewController:alertVC animated:YES completion:nil];}}];
}// 验证权限
- (void)checkAuthorizateCameraWithBlock:(void(^)(BOOL cameraAuthSuccess, BOOL albumAuthSuccess))block {[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {dispatch_async(dispatch_get_main_queue(), ^{NSInteger cameraAuth = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];block(cameraAuth != AVAuthorizationStatusDenied, status != PHAuthorizationStatusDenied);});}];
}

http://www.taodudu.cc/news/show-1912842.html

相关文章:

  • IOS-播放器开发(1)-视频基本原理
  • iOS多线程(一):GCD的基本使用
  • Dart教程(一):dart安装
  • Dart教程(二):基本语法
  • Dart教程(三):类的定义和使用
  • IOS:static和extern的使用
  • MQTT教程(一):MQTT简介
  • MQTT教程(二):MQTT中的可变报头
  • 转:互联网协议入门(一)
  • iOS:tintColor详解
  • iOS数据库的使用(一):FMDB多线程
  • iOS数据库的使用(二):sqlite教程
  • iOS数据库的使用(三):sqlite多线程
  • C语言底层原理(一):预处理、编译、汇编、链接
  • C语言底层原理(二):动态库、静态库
  • 如何买基金(一):三分钟读懂基金分类
  • Flutter:布局
  • sqlite:WAL模式
  • pod install pod update
  • Flutter安装
  • dart安装:sdk下载地址( 2.4.0)
  • 小程序快速入门:小程序的基本结构
  • 小程序快速入门:wxml的使用
  • iOS开发快速入门javascript
  • flutter教程(一):基本语法
  • flutter教程(二):布局
  • javascript快速入门(二):JS浏览器操作
  • Dart教程(四):语法
  • 小程序快速入门:wxss的使用
  • 小程序快速入门:坏境和生命周期

iOS:跳转设置界面,权限相关,UIApplicationOpenSettingsURLString的使用相关推荐

  1. 第四十九篇、跳转设置界面

    跳转方式: //蓝牙设置界面 NSURL *url = [NSURL URLWithString:@"prefs:root=Bluetooth"]; if ([[UIApplica ...

  2. ios应用在设置网络权限为wifi和数据后会被还原为关闭

    这个问题困扰了我很久,一开始我还以为是我直接xcode安装的测试包的原因,结果发现原来是ios13.5版本的bug!经过多方测试后无效,网上说的唯一的解决办法是还原设置,这个太复杂了,我选择了升级版本 ...

  3. 服务器网站权限,在服务器上设置网站权限

    在服务器上设置网站权限 内容精选 换一换 开发过程中,您有任何问题可以在github上提交issue,或者在华为云对象存储服务论坛中发帖求助.接口参考文档详细介绍了每个接口的参数和使用方法.您可通过以 ...

  4. 服务器网站权限设置,在服务器上设置网站权限

    在服务器上设置网站权限 内容精选 换一换 用户可将自己的桶配置成静态网站托管模式,并通过桶域名访问该静态网站.静态网站托管配置会在两分钟内生效.静态网站所需的网页文件已上传到指定桶中.桶内的静态网站文 ...

  5. 电脑在登陆界面如何打开计算机管理,电脑怎么进入路由器设置界面-168路由网...

    用电脑设置路由器的时候,怎么登录到路由器的管理界面? 其实用电脑登录到路由器设置界面的方法很简单,总结起来就3个步骤: 1.正确连接路由器 2.设置电脑IP地址 3.登录到设置界面 第一步.正确连接路 ...

  6. 域服务器如何限制用户授权访问网站,域控服务器怎么设置用户权限

    域控服务器怎么设置用户权限 内容精选 换一换 如果您需要对华为云上购买的裸金属服务器资源,给企业中的员工设置不同的访问权限,以达到不同员工之间的权限隔离,您可以使用统一身份认证服务(Identity ...

  7. iOS 权限判断 跳转对应设置界面

    相机权限 1.1 使用说明 在合适的地方导入#import <AVFoundation/AVFoundation.h> 使用AVAuthorizationStatus类获取当前权限状态 在 ...

  8. App跳转到权限设置界面

    iOS 10 App跳转到权限设置界面(iOS10之前就不各个记录了) NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLSt ...

  9. Unity 实现跳转ios 设置界面

    Unity 实现跳转ios 设置界面 一.功能需求 iOS网络设置检查,如果没有网络可能是用户选择关闭了 网络链接,ios可以从游戏内直接跳转到设置网络开关. 二.网络检测 直接上代码 public ...

  10. Android:检查通知权限并跳转到通知设置界面

    声明:该方案只对API19及以上版本有效 一.目标需求 最近项目中在完善推送功能,需要进入APP时检测一下是否开启了推送权限,如果没有开启弹窗提醒,当用户点击弹窗时直接跳转到APP的通知设置界面,就像 ...

最新文章

  1. 【Vue】新建一个Vue3项目
  2. MongoDB 日志切换(Rotate Log Files)实战
  3. 多通道ADC一致性的高精度测量方法
  4. linux系统中建立网络白名单,Linux下设置防火墙白名单(RHEL 6和CentOS 7)的步骤
  5. python isinstance和issubclass区别
  6. 建立管理SQL Server登录帐户
  7. php如何安装mysql模块,linux安装php 模块--with-mysql --with-mysqli非得需要安装mysql吗汗血宝马...
  8. 【硬件解码系列】之ffmpeg硬件加速器
  9. Perl 学习笔记-输入输出
  10. 第四季-专题5-内核模块开发
  11. YII 框架相关收藏
  12. HDU---3642:Get The Treasury【立方体体积并】
  13. 搜索引擎算法之同义词、近义词、上位词挖掘
  14. 机器人轨迹规划(熊友伦)
  15. windows防火墙规则_如何在Windows防火墙中创建高级防火墙规则
  16. 微信小程序实现一些优惠券/卡券
  17. HC-05蓝牙模块AT指令设置教程
  18. k8s 集群部署(dashboard+metrics-server)
  19. 互联网老兵:第一代程序员简晶 最老站长华军
  20. docker搭建fabric

热门文章

  1. js吧键值对变成对象_【面试题】和Vue.js有关的41个基础问题
  2. Oracle表连接方式总结
  3. 面试题之请描述一下Java类加载过程
  4. 一个出色的UI设计师需要具备哪些能力?
  5. 高并发架构系列:最全消息队列有哪些?详解消息队列的选型与应用
  6. 《AutoCAD 2014中文版超级学习手册》——1.2 操作界面
  7. Windows系统服务器IIS7.5 Asp.net支持10万请求的设置方法
  8. Linux标准化:避免重蹈UNIX的覆辙
  9. mac如何清空Recent Places
  10. 在 java 中_关于final 关键字,在Java中,关于final关键字的说法正确的是()