ios10.0相册拍照闪退原因
2016-11-04 20:25
363 查看
iOS10系统下调用系统相册、相机功能,遇到闪退的情况,描述如下:
This app has crashed because it attempted to access privacy-sensitive data without a usage description.The app's Info.plist mustcontain 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闪退 崩溃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>
原文出自:http://www.cnblogs.com/isItOk/p/5875203.html
相关文章推荐
- 调用安卓手机相册和拍照,出现闪退,原因是创建的包名有问题。
- iOS拍照 相册选取 保存PNG图片到Documents下,并利用UICollectionView显示出来
- UIImagePickerController-IOS拍照和选择相册的详细解析(超级全)
- IOS网络第五天 AFN-02-文件上传,底部弹出窗体,拍照和相册获取图片上传
- Unity3D 游戏在 iOS 上因为 trampolines 闪退的原因与解决办法
- iOS--拍照、从相册选图并对图片进行裁剪
- IOS学习笔记39——拍照、从相册选图并对图片进行裁剪
- IOS SDK详解之拍照/相册(默认+自定义拍照界面)
- iOS访问相册及拍照保存的实现实例
- Cocos2d-x 3.x 头像选择器,本地相册与拍照+头像编辑功能(Android、IOS双平台实现)
- iOS开发在js中调用oc可以实现在HTML5中调用手机系统的相册,拍照等。
- IOS学习笔记39——拍照、从相册选图并对图片进行裁剪
- iOS中app启动闪退的原因
- iOS 获取图片(拍照,图库,相册)
- iOS访问相册以及拍照保存至相册的实现
- IOS学习笔记39——拍照、从相册选图并对图片进行裁剪
- IOS实用功能之截图(来自相册和拍照)
- 【学习ios之路:UI系列】点击更换头像实现从相册读取照片和拍照两种功能
- iOS-中app启动闪退的原因
- IOS拍照---》保存到相册----》并且获取照片的ALasset传到相册