title: iOS: UIImagePickerController Issue
body: <p>I'm trying to use UIImagePickerController to grab a photo from the users Photos on their iPhone / iPad. This code works just fine for iPhone, but when I run it on iPad, the debugger gives me the message "<strong>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be presented via UIPopoverController'"</strong>. I'm very new to Objective-C, so I'm unsure of how to edit this code to use UIPopoverController when its being run on the iPad. I'd rather not create 2 new View Controllers, so I was wondering if someone knows what code I would need to add in to have it work on both the iPhone and iPad. Here is the code in my view controllers:</p>
  
  <p>ViewController.h:</p>
  
  <pre><code>    @interface PhotoViewController : UIViewController &lt;UINavigationControllerDelegate, UIImagePickerControllerDelegate&gt; {
          UIButton *grabButton;
          UIImageView *image;
          UIImagePickerController *imgPicker;
      }
      @property (strong, nonatomic) IBOutlet UIButton *grabButton;
      @property (strong, nonatomic) IBOutlet UIImageView *image;
      @property (strong, nonatomic) UIImagePickerController *imgPicker;
  
      - (IBAction)grabImage;
  
      @end
  </code></pre>
  
  <p>ViewController.m:</p>
  
  <pre><code>    #import "PhotoViewController.h"
  
  
      @implementation PhotoViewController
      @synthesize grabButton;
      @synthesize image;
      @synthesize imgPicker;
  
      - (IBAction)grabImage {
          [self presentModalViewController:self.imgPicker animated:YES];
      }
  
      - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
          image.image = img;
          [[picker parentViewController] dismissModalViewControllerAnimated:YES];
      }
  
      - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
      {
          self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
          if (self) {
              self.title = NSLocalizedString(@"Photo Gallery", @"Photo Gallery");
              self.tabBarItem.image = [UIImage imageNamed:@"42-photos.png"];
          }
          return self;
      }
  
      - (void)viewDidLoad
      {
          self.imgPicker = [[UIImagePickerController alloc] init];
          self.imgPicker.allowsImageEditing = YES;
          self.imgPicker.delegate = self;
          self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
          [super viewDidLoad];
      }
  </code></pre>
  
  <p>Thanks in advance!</p>