[英]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>
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.