IOS 10 UIImagePickerController委托没有被调用

问题描述:

我已经设置以下选项,同时使用iPad的图像。问题是委托人似乎永远不会被调用。我已经放置了断点,但它们从未激活过。IOS 10 UIImagePickerController委托没有被调用

.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]; 
} 

任何人都可以看到这个问题?

感谢

+0

看到这一次http://*.com/questions/38236723/ios-10-error-access-private-when-using-uiimagepickercontroller –

+0

我没有复制和粘贴你的代码,你写在新的示例项目中我创建,但它的作品。我没有描述过的一件事就是info.plist隐私照片库的使用。 – boraseoksoon

+0

嗨,检查了info.plist,并且隐私设置已经存在。真的很奇怪,因为我似乎无法找到问题。 – ORStudios

如果使用Xcode8运行项目,请检查项目的Info.plist,确保有对“隐私照片库的使用”一键。

你的代码是正确的,也许问题是info.plist。

+0

嗨,那已经在那里,原来是一个错误,因为重新启动Ipad后,它一切正常。 – ORStudios

我有一个类似的问题,事实证明,挑选图像被选中后,垃圾回收,所以委托没有被调用。

我需要确保在呈现之前对拾取器进行了强有力的引用。

一旦完成,它工作正常。