iOS 10 error [access] when using UIImagePickerController

后端 未结 5 874
野趣味
野趣味 2020-11-28 20:03

I am using XCode 8 and testing with iOS 10.2 Beta.

I have added the Photos, PhotosUI and MobileCoreServices frameworks to project.

Very simple code:

相关标签:
5条回答
  • 2020-11-28 20:23

    In iOS 10, Apple has changed how you can access any user private data types.

    You need to add the Privacy - Photo Library Usage Description key to your app’s Info.plist and their usage information.

    For more information please find the below GIF.

    Or if you want to add via info.plist then you need to add NSPhotoLibraryUsageDescription key.

    Just copy and paste below string in info.plist.

    <key>NSPhotoLibraryUsageDescription</key>
    <string>Take the photo</string>
    

    Please find the below GIF for more information.

    0 讨论(0)
  • 2020-11-28 20:24

    In iOS10, Before you access privacy-sensitive data like Camera, Contacts, and so on, you must ask for the authorization, or your app will crash when you access them.Then Xcode will log like:

    This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSContactsUsageDescription key with a string value explaining to the user how the app uses this data.

    How to deal with this?

    Open the file in your project named info.plist, right click it, opening as Source Code, paste this code below to it. Or you can open info.plist as Property List by default, click the add button, Xcode will give you the suggest completions while typing Privacy - with the help of keyboard ⬆️ and ⬇️.

    Remember to write your description why you ask for this authorization, between <string> and </string>, or your app will be rejected by apple:

    <!--                                                                     
    0 讨论(0)
  • 2020-11-28 20:40

    You may need to put the NSPhotoLibraryUsageDescription in your plist. Like

    <key>NSPhotoLibraryUsageDescription</key>
    <string>$(PRODUCT_NAME) uses photos</string>
    

    Check all the usage descriptions here.

    0 讨论(0)
  • 2020-11-28 20:42

    in iOS 10 you need to add the key mentioned in below image if you are using camera or photo gallery in your app

    0 讨论(0)
  • 2020-11-28 20:45

    You need the add the new privacy settings to you info.plist.

    Don't forget to add the value describing why the app need to access the service.

    0 讨论(0)
提交回复
热议问题