简体   繁体   English

UIImagePickerController在iOS10上崩溃

[英]UIImagePickerController crashes on iOS10

On presenting UIImagePickerController with photo library source on iOS10 , my app crashes. iOS10上呈现带有照片库源的UIImagePickerController时,我的应用程序崩溃了。

On iOS10 with camera source and on iOS9 with photo library and camera sources, the app does not crash. 具有相机源的iOS10和具有照片库和相机源的iOS9上,该应用程序不会崩溃。

The app is written in Swift 2.2 and built by Xcode 7.3.1 . 该应用程序是用Swift 2.2编写的,由Xcode 7.3.1构建。

Why does the crash occur? 为什么会发生崩溃?

let imagePicker = UIImagePickerController()
imagePicker.sourceType = .PhotoLibrary
imagePicker.allowsEditing = true
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion: nil)

堆栈跟踪

You may need to put the NSCameraUsageDescription (if your app uses the Camera) and NSPhotoLibraryUsageDescription (if your app uses the Photo Library) in your plist. 您可能需要在plist中放置NSCameraUsageDescription(如果您的应用使用相机)和NSPhotoLibraryUsageDescription(如果您的应用使用照片库)。 Like below, 如下,

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use your camera</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use your photo library</string>

Rahul's answer is perfect. 拉胡尔的答案是完美的。 If you prefer to add it straight into your plist rather than via the plist's source code then just do the following. 如果您希望将其直接添加到plist中而不是通过plist的源代码,那么只需执行以下操作即可。 plist添加

I solved the crash by updating to the latest Xcode version. 我通过更新到最新的Xcode版本解决了崩溃问题。 The problem has been discussed here as well: https://github.com/Leanplum/Leanplum-iOS-SDK/issues/12 这里也讨论了这个问题: https//github.com/Leanplum/Leanplum-iOS-SDK/issues/12

permission keys in plist for permission For Camera (also need Microphone permission) and PhotoLibrary plist中的权限密钥用于权限相机(也需要麦克风权限)和PhotoLibrary

<key>NSCameraUsageDescription</key>

${PRODUCT_NAME} Camera Usage $ {PRODUCT_NAME}相机使用情况

<key>NSMicrophoneUsageDescription</key>

${PRODUCT_NAME} Microphone Usage $ {PRODUCT_NAME}麦克风使用情况

<key>NSPhotoLibraryUsageDescription</key>

${PRODUCT_NAME} PhotoLibrary Usage $ {PRODUCT_NAME} PhotoLibrary用法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM