使用UIImagePickerController时,iOS 10错误[访问] <私有>

普朗尼C:

我正在使用XCode 8并在iOS 10.2 Beta中进行测试。

我已将Photos,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中可能会更改的内容?

rockdaswift:

您可能需要将NSPhotoLibraryUsageDescription放在您的plist中。喜欢

<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) uses photos</string>

在此处查看所有用法说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章