3

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?

Simon M
  • 2,931
  • 2
  • 22
  • 37

1 Answers1

11

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

myImagePickerController.delegate = self;

also confirm with the UIImagePickerControllerDelegate protocol,

Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
  • Thanks, that worked! Though I'm getting this error (which doesn't seem to affect anything): class 'myClass' does not implement the 'UINavigationControllerDelegate' protocol. I'm assuming that has something to do with not having implemented the UIImagePickerControllerDelegate protocol, but I have no idea how to do that. PS: Forgive my newbieness. :p – Simon M Mar 31 '11 at 08:44
  • It did, but I'm still waiting for an answer to the above comment...\ – Simon M Mar 31 '11 at 21:57
  • 2
  • When this delegate will be called? Will it be called as soon as you shot the pic or once you select use photo in the preview screen? – nOOb iOS Oct 07 '16 at 14:10