-1

当我试图从设备库中选择一张照片时,我正在开发一个通用应用程序

iPad 我收到 SIGABRT 错误,但它在 iPhone 上运行良好

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

提前感谢您的帮助!

4

2 回答 2

1

请阅读以下文档UIImagePickerViewController

该表表明,在 iPad 上,如果您指定源类型UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerControllerSourceTypeSavedPhotosAlbum,则必须使用弹出框控制器呈现图像选取器,如UIPopoverController类参考中的“呈现和关闭弹出框”中所述。如果您尝试以模态方式(全屏)显示图像选择器以在保存的图片和电影中进行选择,系统会引发异常。

在 iPad 上,如果您指定源类型为UIImagePickerControllerSourceTypeCamera,则可以模态(全屏)或使用弹出框呈现图像选择器。但是,Apple 建议您仅全屏显示相机界面。

您必须使用 aUIPopoverController来呈现 iPad 上照片库的图像选择器。

于 2013-03-23T16:28:55.060 回答
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];
于 2013-03-23T17:32:06.517 回答