title: ImagePicker in view hierarchy problem
body: <p>I can't figure out the most effective and "elegant" method for doing some task. The problem definition is:
  I want to display several views, one of them is the ImagePicker with camera roll source.</p>
  
  <p>The hierarchy looks similar to this:
  MAIN VIEW ---> PICKER ---> IMAGE PROCESSING VIEW
  When the user tap "back button" UI has to allow backward displaying.</p>
  
  <p>I have tried several options:</p>
  
  <p>1.</p>
  
  <p>a) MAIN VIEW presents picker view modally.
  b) In didFinishPickingMediaWithInfo delegate method dismiss picker modal view and after that invoke presentModalViewController with IMAGE PROCESSING VIEW.</p>
  
  <p>Sample code:</p>
  
  <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
      UIImage* pickedImage = [info valueForKey:UIImagePickerControllerEditedImage];
      LastViewController* vc = [[LastViewController alloc] init];
      vc.mainImage = pickedImage;
  
      [self dismissModalViewControllerAnimated:NO];
  
      [self presentModalViewController:vc animated:NO];
  }
  </code></pre>
  
  <p>Problem is that, it doesn't works, cause controller can't display next modal after dismissing another (previouse won't disappear immediately, MAIN isn't active immediately, and can't present the new one).</p>
  
  <p>2.
  MAIN VIEW presents IMAGE PROCESSING VIEW modally, but immediately after that IMAGE PROCESSING VIEW is presenting picker view modally, waiting for done, dismissing picker and user can see IMAGE PROCESSING VIEW with image from library.</p>
  
  <p>Sample code:</p>
  
  <p>in some action of main view controller:</p>
  
  <pre><code>ImageProcessViewController *vc = [[ImageProcessViewController alloc] initWithNibName:@"ImageProcessViewController" bundle:nil];
  vc.delegate = self;
  vc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  [self presentModalViewController:vc animated:NO];
  [vc release];
  </code></pre>
  
  <p>in ImageProcessViewController:</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
  
      //some UI init here
  
      if(self.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
          UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
          ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
          ipc.delegate = self;
          ipc.allowsEditing = YES;
          [self presentModalViewController:ipc animated:NO];
          [ipc release];
      }
  }
  
  - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
      UIImage* pickedImage = [info valueForKey:UIImagePickerControllerEditedImage];
      self.mainImage = pickedImage;
  
      [self dismissModalViewControllerAnimated:NO];
  }
  </code></pre>
  
  <p>Problem is that, i can't call presentModalViewController in viewDidLoad method because it won't work (it is too early in view controller live cycle I guess). I tried also in viewDidAppear, but in that case I have to set some ivar flag, to display picker view only once and empty IMAGE PROCESSING VIEW is displayed for short time before image picker view and i don't want this.</p>
  
  <p>3.
  I tried to figure out how to use Navigation Controller to do this, beacause UIImagePickerController is using his nav controller, but this is private structure and documentation says programmers can't do that.</p>
  
  <p>Please give me some suggestions because I really lost my way at the moment </p>