2013-03-23 110 views
-1

我一个通用的应用程序的工作,试图选择在presentViewController SIGABRT

了iPad,我收到了SIGABRT错误从设备库中的照片时,但它工作正常在iPhone

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

感谢您提前提供任何帮助!

+0

你是如何实例化选取器的? – WolfLink 2013-03-23 16:20:33

+0

什么操作系统都在运行? – 2013-03-23 16:24:13

+0

请注意,您应该在控制台中看到完整的错误消息。错误清楚地说明了问题所在。 – rmaddy 2013-03-23 16:30:12

回答

1

请阅读文档为UIImagePickerViewController

该表显示,在iPad,如果指定的UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerControllerSourceTypeSavedPhotosAlbum源类型,则必须使用一个酥料饼控制器呈现图像选择器,如描述于“在UIPopoverController类参考中呈现和解除Popover“。如果您尝试以模态方式显示图像选择器(全屏)以在保存的照片和动画中进行选择,则系统会引发异常。

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

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

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];