0

I have an application that allows a user to add a picture to a log. If the user chooses to add from library, everything is fine, but if a user chooses to take a picture with the camera there's an issue:

When the camera modal view is animated in and I either take a picture and tap on "Use" or i click on the "Cancel" button, the view I'm in when calling dismissModalViewAnimated is removed from its superview.

Anyone got an explanation for this?

Here's the code I use for presenting the modal viewcontroller

pickerCont = [[UIImagePickerController alloc] init];
pickerCont.delegate = self;
pickerCont.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:pickerCont animated:YES];

And this is what i use to dismiss it:

[self dismissModalViewControllerAnimated:YES]
PinkFloydRocks
  • 808
  • 3
  • 14
  • 29

1 Answers1

1

Actually you are dissmissing parentview. here self represents parentView

Use UIImagePickerController's delegate to dissmiss UIImagePickerController

 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   //get picked image here

   [pickerCont dismissModalViewControllerAnimated:YES]

}
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
  • How right you are! I thought I'd already tried that solution, but it seems I re-init'ed the pickerCont and then tried [pickerCont dismissModalViewControllerAnimated:YES] :-S Thanks for opening my overworked eyes, Prince! – PinkFloydRocks Sep 14 '12 at 08:32