UIImagePickerController didFinishPickingMediaWithInfo未被调用

时间:2011-03-31 05:41:26

标签: iphone uiimagepickercontroller

我在使用UIImagePickerController时遇到了麻烦。基本上,虽然选择器显示正常,但UIImagePickerController didFinishPickingMediaWithInfo方法拒绝被调用(我已经尝试过NSLogging,它只是没有被调用)。这是我的代码(我在头文件中将imgPicker定义为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];
}

任何人都知道为什么没有被召唤?

1 个答案:

答案 0 :(得分:11)

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

myImagePickerController.delegate = self;

也使用UIImagePickerControllerDelegate协议确认