zoukankan      html  css  js  c++  java
  • 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>

    WDC2106 iOS10新特性及开发者要注意什么

  • 相关阅读:
    cat
    cal
    API、ABI区别
    html 实体转换为字符:转换 UEditor 编辑器 ( 在 ThinkPHP 3.2.2 中 ) 保存的数据
    IDEA突然无法运行
    Java实现 蓝桥杯 算法提高 成绩排名
    Java实现 蓝桥杯 算法提高 成绩排名
    Java实现 蓝桥杯 算法提高 成绩排名
    Java实现 蓝桥杯 算法提高 Monday-Saturday质因子
    Java实现 蓝桥杯 算法提高 Monday-Saturday质因子
  • 原文地址:https://www.cnblogs.com/isItOk/p/5875203.html
Copyright © 2011-2022 走看看