UIImagePickerController didFinishPickingMediaWithInfo未被调用 [英] UIImagePickerController didFinishPickingMediaWithInfo not being called

查看:201
本文介绍了UIImagePickerController didFinishPickingMediaWithInfo未被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用UIImagePickerController时遇到了麻烦。基本上,尽管选择器显示正常,但UIImagePickerController didFinishPickingMediaWithInfo方法拒绝被调用(我已经尝试过NSLogging,它只是没有被调用)。这是我的代码(我在标题中将imgPicker定义为UIImagePickerController):

I'm having trouble with using a UIImagePickerController. Basically, though the picker is being displayed fine, the UIImagePickerController didFinishPickingMediaWithInfo method is refusing to be called (I've tried NSLogging all the way through, it just doesn't get called). Here's my code (I've defined imgPicker in the header as an UIImagePickerController):

-(IBAction)grabImage {
    self.imgPicker = [[UIImagePickerController alloc] init];
    self.imgPicker.allowsImageEditing = YES;
    self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    [self presentModalViewController:self.imgPicker animated:YES];
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    imgview.image = [info objectForKey:UIImagePickerControllerEditedImage];
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}

任何人都知道为什么没有被调用?

Anyone have any idea as to why it isn't being called?

推荐答案

您是否设置了 UIImagePickerController 的委托属性,如果不是,请执行以下操作

Have you set the delegate property of UIImagePickerController , if not do as below

myImagePickerController.delegate = self;

还确认 UIImagePickerControllerDelegate 协议,

这篇关于UIImagePickerController didFinishPickingMediaWithInfo未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆