1、判断用户是否获取了相册的访问权限

#import <AssetsLibrary/AssetsLibrary.h>// 获取相册权限
- (void)getPhotoLibraryAuthor {ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];if (status == ALAuthorizationStatusRestricted || status == ALAuthorizationStatusDenied) {UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"请开启相册权限\n 设置 -> 隐私 -> 照片" preferredStyle:UIAlertControllerStyleAlert];[alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];[self presentViewController:alertVc animated:YES completion:nil];} else {[self openPhotoLibrary];}
}

2、判断用户是否获取了相机的访问权限

#import <AVFoundation/AVMediaFormat.h>
#import <AVFoundation/AVCaptureDevice.h>// 获取相机权限
- (void)getCameraAuthor {AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];if (status == AVAuthorizationStatusRestricted || status == AVAuthorizationStatusDenied) {UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"请开启相机访问权限\n 设置 -> 隐私 -> 相机" preferredStyle:UIAlertControllerStyleAlert];[alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];[self presentViewController:alertVc animated:YES completion:nil];} else {[self openCamera];}
}

3、判断用户是否获取了麦克风的访问权限

#import <AVFoundation/AVFoundation.h>- (BOOL)getMicrophoneAuthor {__block BOOL canRecord = YES;if ([self.audioSession respondsToSelector:@selector(requestRecordPermission:)]) {[self.audioSession performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {if (granted) {canRecord = YES;} else {canRecord = NO;UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"请开启麦克风访问权限:\n设置 -> 隐私 -> 麦克风" preferredStyle:UIAlertControllerStyleAlert];[alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];[self presentViewController:alertVc animated:YES completion:nil];}}];}return canRecord;
}

4、判断用户是否获取了定位的访问权限

//检测的是整个的iOS系统的定位服务是否开启
[CLLocationManagerlocationServicesEnabled]//检测当前应用的定位服务是否开启需要通过一下方法来检测
- (void)locationManager:(CLLocationManager*)managerdidFailWithError:(NSError*)error {UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"请开启定位权限:\n设置 -> 隐私 -> 定位服务" preferredStyle:UIAlertControllerStyleAlert];[alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];[self presentViewController:alertVc animated:YES completion:nil];
}**或者是下面这个可以尝试一下:**- (void)getLocationAuthor {CLAuthorizationStatus status = [CLLocationManager authorizationStatus];  if (status == kCLAuthorizationStatusDenied || status == kCLAuthorizationStatusRestricted) {  UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"请开启定位权限:\n设置 -> 隐私 -> 定位服务" preferredStyle:UIAlertControllerStyleAlert];[alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];[self presentViewController:alertVc animated:YES completion:nil];  }
}

iOS中获取相册、相机、定位、以及麦克风权限设置相关推荐

  1. IOS中获取各个文件的目录路径的方法和NSFileManager类

    转自:http://blog.sina.com.cn/s/blog_5fb39f910101di92.html IOS中获取各种文件的目录路径的方法 iphone沙箱模型的有四个文件夹,分别是什么,永 ...

  2. android 麦克风权限设置,绝地求生刺激战场麦克风权限怎么设置?刺激战场麦克风权限设置方法[多图]...

    绝地求生刺激战场麦克风权限有哪些方法设置?麦克风可以和玩家之间进行沟通,但是有时候开了语音也没有声音,下面就让安卓乐园小编为大家带来,刺激战场麦克风权限设置方法. 绝地求生刺激战场语音怎么没声音 1. ...

  3. iOS - 中获取各种文件的目录路径的方法

    转自:https://www.cnblogs.com/zrr-notes/p/5953445.html 我们的app在手机中存放的路径是:/var/mobile/Applications/4434-4 ...

  4. chrome修改摄像头权限_如何在Chrome中更改网站的摄像头和麦克风权限

    chrome修改摄像头权限 Google Chrome lets you manage which individual sites can have access to your microphon ...

  5. iOS中获取WiFi的SSID(CNCopySupportedInterfaces())

    获取当前设备连接WiFi: ios5之前可以通过读取配置文件获取,ios5以后苹果修改wifi列表文件位置,只有root权限才可以读取. ios4:/System/Library/SystemConf ...

  6. iPhone PHP获取文件,IOS中获取各种文件的目录路径的方法

    iphone沙箱模型的有四个文件夹,分别是什么,永久数据存储一般放在什么位置,得到模拟器的路径的简单方式是什么. documents,tmp,app,Library. (NSHomeDirectory ...

  7. IOS中CoreLocation框架地理定位

    1.CoreLocation框架使用前提: #import <CoreLocation/CoreLocation.h> CoreLocation框架中所有数据类型的前缀都是CL ,Core ...

  8. (转)IOS中获取各种文件的目录路径的方法

    iphone沙箱模型的有四个文件夹,分别是什么,永久数据存储一般放在什么位置,得到模拟器的路径的简单方式是什么.documents,tmp,app,Library.(NSHomeDirectory() ...

  9. ios中获取各种文件的目录路径方法

    2019独角兽企业重金招聘Python工程师标准>>> iphone沙箱模型的有四个文件夹,分别是什么,永久数据存储一般放在什么位置,得到模拟器的路径的简单方式是什么. docume ...

最新文章

  1. android屏幕分辨率详解 ldpi mdpi hdpi 程序UI自适应 《官方翻译》
  2. Git命令按人统计提交次数和代码量
  3. 深圳电信网速测试工具
  4. 放置奇兵 新 粉石墨
  5. SpringMVC异常处理机制-异常处理两种方式
  6. linux中的memory management和page mapping
  7. SSIA的完整形式是什么?
  8. Android实现异步处理 -- HTTP请求
  9. 9203 0409 随堂
  10. 【java】分布式一致性hash算法
  11. java.io.IOException: http://XXX provided port:50000 is not reachable
  12. 套利进阶——简单易行的分级基金套利
  13. BZOJ4484: [Jsoi2015]最小表示
  14. debian使用FTP详细配置教程
  15. c++ 中字符串的字符数与字节数
  16. ClassNotFoundException,某种类的缺失
  17. python教学小说05 宽容之心,是容纳世界的神奇变量。
  18. 六月集训(第21天) —— 堆(优先队列)
  19. 青春无敌?那只是一瞬间
  20. vue——数字加逗号分隔

热门文章

  1. 2019电赛所需仪器设备和主要元器件清单
  2. IOS如何给VIEW设置2个圆角?set cornerRadius for only top-left and top-right corner of a UIVIEW
  3. hive中的逻辑运算符 案列_Hive 教程(官方Tutorial)
  4. 覆盖索引是什么?一篇文章告诉你
  5. 基金申请-4:如何检索国家基金科研项目?
  6. [论文评析]Balanced MSE for Imbalanced Visual Regression,CVPR,2022
  7. python的常见矩阵除法_numpy常用矩阵运算方法【转】
  8. 使用Tomcat10.0.10搭建一个文件下载服务器
  9. HostMonitor是一款功能强大的运维管理软件
  10. Web3的2048,Sui 8192能否打开全链游戏的大门?