iOS开发 Xcode8调用相机问题

一 ,遇到的问题


1 权限问题设置

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>NSPhotoLibraryUsageDescription</key>
    <string>App需要您的同意,才能访问相册</string>

    <key>NSCameraUsageDescription</key>
    <string>App需要您的同意,才能访问相机</string>

    <key>NSMicrophoneUsageDescription</key>
    <string>App需要您的同意,才能访问麦克风</string>

    <key>NSLocationUsageDescription</key>
    <string>App需要您的同意,才能访问位置</string>

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>App需要您的同意,才能在使用期间访问位置</string>

    <key>NSLocationAlwaysUsageDescription</key>
    <string>App需要您的同意,才能始终访问位置</string>

    <key>NSCalendarsUsageDescription</key>
    <string>App需要您的同意,才能访问日历</string>

    <key>NSRemindersUsageDescription</key>
    <string>App需要您的同意,才能访问提醒事项</string>

    <key>NSMotionUsageDescription</key> <string>App需要您的同意,才能访问运动与健身</string>

    <key>NSHealthUpdateUsageDescription</key>
    <string>App需要您的同意,才能访问健康更新 </string>

    <key>NSHealthShareUsageDescription</key>
    <string>App需要您的同意,才能访问健康分享</string>

    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>App需要您的同意,才能访问蓝牙</string>

    <key>NSAppleMusicUsageDescription</key>
    <string>App需要您的同意,才能访问媒体资料库</string>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容