title: I am trying to use a UIPopoverContoller to load an image
body: <p>I am making a simple universal image loader in xcode 4.2, it allows you to choose a photo from the phone library and display it on the screen. It is a universal app and works fine using UIImagePickerController to pull up a menu and select a photo but when a click the button on the ipad that should display the popoverController button it returns an error. </p>
  
  <pre><code>#import "ImageLoaderViewController.h"
  
  @implementation ImageLoaderViewController
  @synthesize imageView = _imageView;
  @synthesize popoverController;
  
  -(void)selectPhoto
  {
      NSLog(@"YYOYOYOYOY");
  
      UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
      NSLog(@"now i am here");
      imagePicker.delegate = self;
  
      if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
      {
          NSLog(@"camera");
          imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
      }
      else{
          NSLog(@"NO camera");
          imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;}
      if(IS_IPHONE)
      {
          NSLog(@"is an iphone");
          [self presentModalViewController:imagePicker animated:YES];
      }
  
      else
      {
          if ([popoverController isPopoverVisible])
              [popoverController dismissPopoverAnimated:NO];
          popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
          popoverController.delegate = self;
          [popoverController presentPopoverFromBarButtonItem:self.navigationItem.rightBarButtonItem permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
  
      }
  
  }
  
  -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  {
      _imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
      if(IS_IPHONE)
          [self dismissModalViewControllerAnimated:NO];
  }
  
  -(void) popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
  {
      [popoverController dismissPopoverAnimated:NO];
  }
  
  
  
  @end
  </code></pre>