【发布时间】:2017-02-09 20:48:04
【问题描述】:
我已设置以下内容以在使用 iPad 时选择图像。问题是委托似乎永远不会被调用。我已经放置了断点,但它们从未被激活。
.H
@interface HomeViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
.M
- (IBAction)loadImage:(id)sender {
self.imagePickerController = [[UIImagePickerController alloc] init];
self.imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
self.imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
self.imagePickerController.allowsEditing = NO;
self.imagePickerController.delegate = self;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
}
// This method is called when an image has been chosen from the library or taken from the camera.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//You can retrieve the actual UIImage
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
//Or you can get the image url from AssetsLibrary
NSURL *path = [info valueForKey:UIImagePickerControllerReferenceURL];
[picker dismissViewControllerAnimated:YES completion:nil];
}
谁能看到这个问题?
谢谢
【问题讨论】:
-
我确实复制并粘贴了您在我创建的新示例项目中编写的代码,但它可以工作。我在没有您描述的情况下添加的一件事是 info.plist 隐私照片库的使用。
-
嗨,检查了 info.plist 并且隐私设置已经存在。真的很奇怪,因为我似乎找不到问题。
-
它对我来说也很好用
-
每个人都在使用 iPad 吗?
标签: ios objective-c