iOS10相册相机闪退bug
iOS10系统下调用系统相册、相机功能,遇到闪退的情况,描述如下:
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.
修复方法:
在info.plist文件下添加
相机权限
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
相册权限
<key>NSPhotoLibraryUsageDescription</key>
<string>photoLibraryDesciption</string>
===========================
说法二
升级iOS10之后,在应用访问相册、相机、话筒、听筒的时候会发生崩溃。例如访问相机的时候xcode打印崩溃信息:
“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.”
这是因为iOS对于隐私权限的配置更为严格。但是我看不出来哪里好了,用着还不方便。
解决办法:
更改info.plist文件,可以直接用文本打开,添加:
<key>NSCameraUsageDescription</key> <string>cameraDesciption</string> <key>NSContactsUsageDescription</key> <string>contactsDesciption</string> <key>NSMicrophoneUsageDescription</key> <string>microphoneDesciption</string> <key>NSPhotoLibraryUsageDescription</key> <string>photoLibraryDesciption</string>
也可以直接在xcode中更改:
这个string是我们开发者给起的一个表示,意思就是能随便写,但是要能表明其含义,它是给用户看的。第一次访问这些外设的时候会弹出提示框,上面就有显示这个string:
其它的权限key:
// 相机
NSCameraUsageDescription
// 相册
NSPhotoLibraryUsageDescription
// 麦克风:
NSMicrophoneUsageDescription
// 通信录
NSContactsUsageDescription
// 位置
NSLocationUsageDescription
// 日历
NSCalendarsUsageDescription
// 蓝牙
NSBluetoothPeripheralUsageDescription
// 媒体资料库
NSAppleMusicUsageDescription
// 提醒事项
NSRemindersUsageDescription
// 在使用期间访问位置
NSLocationWhenInUseUsageDescription
// 始终访问位置
NSLocationAlwaysUsageDescription
// 运动与健身
NSMotionUsageDescription
更多iOS10的特性参考官方文档:点击打开链接
==================================
iOS10闪退 崩溃1:
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.
意思是说:你需要在info.plist文件 添加一个“NSContactsUsageDescription ”的Key,Value添加一个描述。
需要在应用的info.plist里加入(使用source code模式):
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
<key>NSContactsUsageDescription</key>
<string>contactsDesciption</string>
<key>NSMicrophoneUsageDescription</key>
<string>microphoneDesciption</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photoLibraryDesciption</string>
posted on 2016-09-15 18:38 🌞Bob 阅读(5446) 评论(0) 编辑 收藏 举报