当我尝试从
上的设备库中选择照片时,我正在开发一款通用应用iPad我收到SIGABRT错误,但它在iPhone上运行良好
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil]; //the culprit, why?
提前感谢您的帮助!
答案 0 :(得分:1)
请阅读UIImagePickerViewController
的文档:
该表格表明,在iPad上,如果指定的源类型为
UIImagePickerControllerSourceTypePhotoLibrary
或UIImagePickerControllerSourceTypeSavedPhotosAlbum
,则必须使用弹出控制器显示图像选择器,如“演示和关闭弹出窗口”中所述在UIPopoverController
类参考中。如果您尝试以模态方式(全屏)显示图像选择器,以便在保存的图片和电影中进行选择,系统会引发异常。在iPad上,如果指定的源类型为
UIImagePickerControllerSourceTypeCamera
,则可以模态(全屏)或使用弹出窗口显示图像选择器。但是,Apple建议您仅以全屏方式显示相机界面。
您必须使用UIPopoverController
在iPad上展示照片库的图像选择器。
答案 1 :(得分: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];