-1

I am working on a universal app, when trying to select a photo from the devices library on

the iPad I get a SIGABRT error, but it works fine on the iPhone

   picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
   [self presentViewController:picker animated:YES completion:nil];  //the culprit, why?

Thanks for any help in advance!

Vishal
  • 8,246
  • 6
  • 37
  • 52
user906357
  • 4,575
  • 7
  • 28
  • 38

2 Answers2

1

Please read the docs for UIImagePickerViewController:

The table indicates that on iPad, if you specify a source type of UIImagePickerControllerSourceTypePhotoLibrary or UIImagePickerControllerSourceTypeSavedPhotosAlbum, you must present the image picker using a popover controller, as described in “Presenting and Dismissing the Popover” in UIPopoverController Class Reference. If you attempt to present an image picker modally (full-screen) for choosing among saved pictures and movies, the system raises an exception.

On iPad, if you specify a source type of UIImagePickerControllerSourceTypeCamera, you can present the image picker modally (full-screen) or by using a popover. However, Apple recommends that you present the camera interface only full-screen.

You must use a UIPopoverController to present the image picker for the photo library on the iPad.

Community
  • 1
  • 1
rmaddy
  • 314,917
  • 42
  • 532
  • 579
0
        // While showing UIImagePickerController in iPad, you must do it using UIPopoverController as follow 


        // Declare UIPopoverController and present your UIImagePickerController using it
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
        [imagePicker setDelegate:self];
        [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
        [imagePicker setAllowsEditing:YES];

        popOverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
        [popOverController presentPopoverFromRect:self.view.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
Dipen Panchasara
  • 13,480
  • 5
  • 47
  • 57