gpt4 book ai didi

使用 UIImagePickerController 时 iOS 10 错误 [访问]

转载 作者:IT老高 更新时间:2023-10-28 12:21:48 25 4
gpt4 key购买 nike

我正在使用 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 中可能会更改的内容?

最佳答案

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

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

查看所有使用说明here .

关于使用 UIImagePickerController 时 iOS 10 错误 [访问] <private>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38236723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com