title: UIPopoverController and UIImagePickerController crash
body: <p>Here is the set up of my view:</p>
  
  <p><img src="https://i.stack.imgur.com/kiqtO.png" alt="View Setup"></p>
  
  <p>When the <code>UIBarButtonItem</code> is clicked, it should bring up a <code>UIImagePickerController</code>.  I have to do this using a <code>UIPopoverController</code>, which is invoked by clicking on the "reset" button, because it is necessary on the iPad. Here is my code:</p>
  
  <pre><code>-(IBAction) btnReset:(id)sender {
      [self chooseImage];
  }
  
  -(void) chooseImage {
      if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
          imagepicker = [[UIImagePickerController alloc] init];
          imagepicker.allowsEditing = NO;
          imagepicker.delegate = self;
          imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
          imagepicker.navigationBar.opaque = true;
  
  
          if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
              popoverController = [[UIPopoverController alloc] initWithContentViewController:imagepicker];
  
              [popoverController presentPopoverFromBarButtonItem:reset permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
  
          } else {
              [self presentModalViewController:imagepicker animated:YES];   
          }
      }
  }
  </code></pre>
  
  <p>However, when this is called, the view crashes with the error:</p>
  
  <blockquote>
    <p>'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'</p>
  </blockquote>
  
  <p>What am I doing wrong? Thank you in advance.</p>