1. 程式人生 > >iOS10 UIImageWriteToSavedPhotosAlbum程序奔潰crash解決辦法

iOS10 UIImageWriteToSavedPhotosAlbum程序奔潰crash解決辦法

sca sde rop acc because data ima tsd con

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 NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

解決方案
1.在項目中找到info.plist文件,右鍵點擊以 Source Code

形式打開
2.添加以下鍵值對,這裏以 PhotoLibrary 作為例子

    <key>NSPhotoLibraryUsageDescription</key>
    <string>此 App 需要您的同意才能讀取媒體資料庫</string>



目測所有需要的權限描述都會在 iOS 10 beta裏面crash,不用怕,控制臺會有輸出的,自行添加就 OK,我另外附送幾個 key/value 給你們

    <key>NSCameraUsageDescription</key>    
    <string>cameraDesciption</string>

    <key>NSContactsUsageDescription</key>    
    <string>contactsDesciption</string>

    <key>NSMicrophoneUsageDescription</key>    
    <string>microphoneDesciption</string>

嗯,然後 clean 一下,重新運行。

iOS10 UIImageWriteToSavedPhotosAlbum程序奔潰crash解決辦法