在研究了 UIImagePickerController 之后,我得到了这个代码来从弹出窗口中选择一个图像,然后在 myParticularImageView 中显示它。
这是 ViewController.m:
@interface ViewController () {
UIImagePickerController *imagePickerController;
UIPopoverController *popover;
}
@end
- (IBAction)chooseImageButtonPressed:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[popover setDelegate:self];
[popover presentPopoverFromRect:((UIButton *)sender).frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
//then to dismiss the popover and display pic
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[[self myParticularImageView] setImage:image];
[popover dismissPopoverAnimated:YES];
}
@end
我遇到的问题是,当我从弹出窗口中点击图片时,什么也没有发生。
在 .h 我得到:
:UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIPopoverControllerDelegate>
什么可能导致我的问题,我该如何解决?