我正在使用XCode 8,并使用iOS 10.2Beta进行测试。
我已经添加了照片,PhotosUI和MobileCoreServices框架项目。
非常简单的代码:
#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];
}我一点击按钮,应用程序就崩溃了,并出现了非常无用的错误:
[access] <private>
就这样。没别的了。
使用break语句,应用程序似乎在"presentViewController“时崩溃。
这是一个全新的应用程序,除了抓取按钮之外,我的UI中没有其他任何东西。
此外,在iOS 9.3上进行测试时,这种方法工作得很好。我是否遗漏了iOS 10中可能发生更改的内容?
发布于 2016-07-07 16:59:30
您可能需要将NSPhotoLibraryUsageDescription放在plist中。喜欢
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) uses photos</string>检查所有的用法描述here。
发布于 2016-09-19 14:19:29
在iOS 10中,如果您在应用程序中使用相机或图片库,则需要添加下图中提到的密钥

https://stackoverflow.com/questions/38236723
复制相似问题