Search code examples
iphoneiosipadsigabrtios-universal-app

presentViewController SIGABRT


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!


Solution

  • 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.