title: Dismiss Modalview after imagePickerController:didFinishPickingMediaWithInfo:
body: <p>I have a ViewController (VC1) that opens another ViewController (VC2) modally that is embedded in a NavigationController (NavC1). VC2 is used as a source selection view for the user to select different sources, such as the built-in photo library. When the user selects the photo library in VC2 I am opening Apple's imagePicker.</p>
  
  <p><code>VC1 --(modal)--&gt; NavC1 ----&gt; VC2</code></p>
  
  <p>In the imagePickerdidFinish I would like to close the before modally presented VC2.
  Actually this method looks as follows.</p>
  
  <pre><code>-(void)imagePickerController:(UIImagePickerController *)picker
  didFinishPickingMediaWithInfo:(NSDictionary *)info
  {
      UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
  
      ...
  
      NSError* error;
      if([UIImageJPEGRepresentation(image, 0.5) writeToFile:path options:NSDataWritingFileProtectionComplete error:&amp;error] == NO)
      {
          NSLog(@"Saving image to file failed with error %@",[error localizedDescription]);
      }
  
      picker.delegate = nil;
      [self dismissModalViewControllerAnimated:YES];
      ...
  }
  </code></pre>
  
  <p>What I have tried so far:</p>
  
  <ul>
  <li>I have tried to dismiss it using the parent navigation controller</li>
  <li>I have stored a reference to VC2 in <code>prepareForSegue:</code> of VC1 and
  passed a delegate back to VC1 from VC2 when the imagePicker did
  finish. In this method I have tried to simply dimiss the modal view
  manually (<code>[self.myModalView
  dismissModalViewControllerAnimated:YES]</code>)</li>
  </ul>
  
  <p>Does anyone have a suggestion for me? Thanks in advance!</p>