【发布时间】:2023-03-19 20:54:02
【问题描述】:
我正在尝试链接我的照片库以在 UIImageView 中显示图像,这将允许我添加过滤器,但是当您选择照片并点击“选择”时,应用程序崩溃。下面是我正在使用的代码; - (IBAction)chooseImage:(id)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
}
错误在以下行:
"picker.delegate = self;"
并记为 *"Assigning to 'id' from in compatible type 'VSViewController const_strong'
如果有人对如何修复它或将运行的替代代码提出建议,我们将不胜感激。
请尽量避免使用过于复杂的语言,我是编码新手,这个问题让我沮丧了一段时间。
【问题讨论】:
-
您是否已将 UIImagePickerController 委托包含到您的 .h 中?
-
我不这么认为,那是什么编码?
-
在 VSAppDelegate.h 还是 VSViewController.h 下?我都试过了,但都没有'@protocol'
-
@JMarsh 很可能是指
@interface,而不是@protocol。
标签: ios objective-c xcode5 appdelegate photolibrary