美文网首页iOS开发iOS学习笔记程序员
OC - 解决iOS10相册,相机,麦克风,通讯录等权限使用问题

OC - 解决iOS10相册,相机,麦克风,通讯录等权限使用问题

作者: 好少年 | 来源:发表于2016-11-08 10:40 被阅读1283次

错误情况:

iOS10之后,使用Xcode 进行真机测试时,涉及设备权限使用的时候,会出现crash的情况:

| 调用照片库权限 |

 [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data. |

| 调用相机权限 |

[access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.|

| 调用麦克风权限 |

 [access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app's Info.plist must contain an NSMicrophoneUsageDescription key with a string value explaining to the user how the app uses this data.|

解决:

需要使用某一权限时,在Info.plist里面添加一个String字段即可:

所需权限 相应字段
相机权限 NSCameraUsageDescription
照片库权限 NSPhotoLibraryUsageDescription
麦克风权限 NSMicrophoneUsageDescription
定位权限(始终) NSLocationAlwaysUsageDescription
定位问题(使用应用期间) NSLocationWhenInUseUsageDescription

以上是部分示例,其他权限,在Info.plist文件中,添加一栏:输入 “Privacy - ”自动列出供选择
Privacy - Camera Usage Description
Privacy - Photo Library Usage Description
Privacy - Calendars Usage Description

配置完成后,进入APP,使用相应功能时,系统会弹窗提示使用相关权限。

End。

相关文章

网友评论

    本文标题:OC - 解决iOS10相册,相机,麦克风,通讯录等权限使用问题

    本文链接:https://www.haomeiwen.com/subject/pqsauttx.html