title: Choosing Photos and Taking from camera on iPad
body: <p>I'm using the same .h and .m files for both iPhone and iPad xibs. I would like to capture an image or choose from photos on tap of a button. How do I do this? If I choose from photos on a pop over, I get the photo gallery but doesn't select the photo and the camera doesn't open if I choose from camera! Everything works fine on iPhone, though. Here is the code I'm using:</p>
  
  <pre><code>-(IBAction)getPhotos:(id)sender
  {
      self.action = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Take New Photo",@"Choose From Existing",@"Remove Photo",@"Cancel", nil];
      self.action.actionSheetStyle = UIActionSheetStyleAutomatic;
      self.action.destructiveButtonIndex = 2;
      if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
      {
          [self.action showInView:self.view];
      }
      else
      {
  
          [self.action showFromRect:self.button1.frame inView:self.view animated:YES];
  
      }
  }
  
  
  -(void)actionSheet:(UIActionSheet *)popup clickedButtonAtIndex:(NSInteger)buttonIndex
  {
      if (buttonIndex == 0)
      {
          [self TakePhotoWithCamera];
      }
      else if (buttonIndex == 1)
      {
          [self SelectPhotoFromLibrary];
      }
      else if(buttonIndex == 2)
      {
          self.imageView.image = [UIImage imageNamed:@"no_photo.png"];
      }
  
  }
  
  -(void) TakePhotoWithCamera
  {
      [self startCameraPickerFromViewController:self usingDelegate:self];
  }
  
  -(void) SelectPhotoFromLibrary
  {
      [self startLibraryPickerFromViewController:self usingDelegate:self];
  }
  
  - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
  {
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  
  - (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id&lt;UIImagePickerControllerDelegate&gt;)delegateObject
  {
      if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
      {
          picker = [[UIImagePickerController alloc] init];
          picker.sourceType = UIImagePickerControllerSourceTypeCamera;
          picker.allowsEditing = YES;
          picker.delegate = self;
          [controller presentViewController:picker animated:YES completion:nil];
      }
      return YES;
  }
  
  - (BOOL)startLibraryPickerFromViewController:(UIViewController*)controller usingDelegate:(id&lt;UIImagePickerControllerDelegate&gt;)delegateObject
  {
      picker = [[UIImagePickerController alloc]init];
      picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
      picker.allowsEditing = YES;
      picker.delegate = self;
       if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
       {
               [controller presentViewController:picker animated:YES completion:nil];
  
      }
  
      else
      {
          popover=[[UIPopoverController alloc]initWithContentViewController:picker];
          [popover presentPopoverFromRect:self.imageView.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
      }
      return YES;
  }
  
  - (void)imagePickerController:(UIImagePickerController *)pickers didFinishPickingMediaWithInfo:(NSDictionary *)info
  {
      if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) {
          [picker dismissViewControllerAnimated:YES completion:nil];
      } else {
          [popover dismissPopoverAnimated:YES];
      }
      self.imageView.image = [info objectForKey:UIImagePickerControllerEditedImage];
  }
  </code></pre>
  
  <p>Please help!!</p>