在iOS10上向UIImagePickerController
展示图片库源代码时,我的应用程序崩溃了。
在有照相源的iOS10和有照片库和照相源的iOS9上,应用程序不会崩溃。
该应用程序是用Swift 2.2编写的,由Xcode 7.3.1构建。
为什么会发生崩溃?
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .PhotoLibrary
imagePicker.allowsEditing = true
imagePicker.delegate = self
self.presentViewController(imagePicker, animated: true, completion: nil)
发布于 2016-09-23 12:56:01
我通过更新到最新的Xcode版本解决了崩溃问题。这里也讨论了这个问题:https://github.com/Leanplum/Leanplum-iOS-SDK/issues/12
发布于 2016-10-05 22:25:12
您可能需要将NSCameraUsageDescription (如果您的应用程序使用相机)和NSPhotoLibraryUsageDescription (如果您的应用程序使用图片库)放在您的plist中。如下所示,
<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>
发布于 2016-10-13 13:00:12
Rahul的回答是完美的。如果你更喜欢将它直接添加到plist中,而不是通过plist的源代码,那么只需执行以下操作。
https://stackoverflow.com/questions/39611490
复制相似问题