在iOS10上呈现UI
ImagePickerController与照片库源,我的应用程序崩溃.
在具有相机源的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)
解决方法
您可能需要将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>