1. 程式人生 > >iOS 10訪問相機Crash,plist許可權設定

iOS 10訪問相機Crash,plist許可權設定

在iOS 10的上訪問相機Crash,打印出以下錯誤資訊
錯誤資訊: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 10的許可權問題
解決:在 info.plist

檔案中新增相應的key和value
這裡寫圖片描述
也可右鍵點選以 Source Code形式開啟,新增如下:

       <key>NSPhotoLibraryUsageDescription</key>
<string>請點選“允許”以允許訪問。</string>
<key>NSCameraUsageDescription</key>
<string>請點選“允許”以允許訪問。</string>
<key>NSAppleMusicUsageDescription</key>
<string
>
請點選“允許”以允許訪問。</string> <key>NSMicrophoneUsageDescription</key> <string>請點選“允許”以允許訪問。</string>

附可能涉及到的許可權:
這裡寫圖片描述