1

I'm able to call the modal view controller for the image picker, pick the image, and crop it, but when I tap 'done' it doesn't do anything, it just hangs with the done button grayed out. There are no errors, but the function is called.

- (void)viewDidLoad
{
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
userImage.image = img;
uploadButton.hidden = NO;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
NSLog(@"called");
}

- (IBAction)getImage:(id)sender {
[self presentModalViewController:self.imgPicker animated:YES];
}
Chris
  • 7,270
  • 19
  • 66
  • 110
  • Does this bug happen every time? – Max Yankov Oct 25 '13 at 14:04
  • 1
    @golergka It's not a bug, by calling `[picker parentViewController]` you would expect `self`, as seen in @Rayfleck's answer. This is because the parent view controller of `picker` is the same controller that presented it in `getImage:` – Chris Oct 25 '13 at 18:41

1 Answers1

2

Replace

 [[picker parentViewController] dismissModalViewControllerAnimated:YES];

with:

 [self dismissModalViewControllerAnimated:YES];
Rayfleck
  • 12,116
  • 8
  • 48
  • 74