iOS 10错误[access]< private>使用UIImagePickerController时 [英] iOS 10 error [access] <private> when using UIImagePickerController
问题描述
我正在使用XCode 8并使用iOS 10.2 Beta进行测试。
I am using XCode 8 and testing with iOS 10.2 Beta.
我已将Photos,PhotosUI和MobileCoreServices框架添加到项目中。
I have added the Photos, PhotosUI and MobileCoreServices frameworks to project.
非常简单的代码:
#import <Photos/Photos.h>
#import <PhotosUI/PhotosUI.h>
#import <MobileCoreServices/MobileCoreServices.h>
@interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, PHLivePhotoViewDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *imageview;
@end
和实施:
- (IBAction)grab:(UIButton *)sender{
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.allowsEditing = NO;
picker.delegate = self;
// make sure we include Live Photos (otherwise we'll only get UIImages)
NSArray *mediaTypes = @[(NSString *)kUTTypeImage, (NSString *)kUTTypeLivePhoto];
picker.mediaTypes = mediaTypes;
// bring up the picker
[self presentViewController:picker animated:YES completion:nil];
}
点击按钮时,应用程序崩溃时出现非常无用的错误:
As soon as I tap the button, the app crashes with very useless error:
[access]< private>
而已。没有别的。
使用break语句,应用程序似乎在presentViewController崩溃。
Using break statements, the app seems to crash at "presentViewController".
这是一个全新的应用程序,除了抓取按钮,我在UI中没有任何其他内容。
This is a brand new app and I don't have anything else in the UI other than the grab button.
此外,在iOS 9.3上测试,这很好用。我错过了iOS 10中可能会更改的内容吗?
Also, testing on iOS 9.3, this works fine. Am I missing something which might be changed in iOS 10?
推荐答案
您可能需要将NSPhotoLibraryUsageDescription放入plist中。
赞
You may need to put the NSPhotoLibraryUsageDescription in your plist. Like
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) uses photos</string>
检查所有使用说明在其他地方。
这篇关于iOS 10错误[access]< private>使用UIImagePickerController时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!