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新特性及開發者要注意什么


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM