【问题标题】:presentViewController SIGABRTpresentViewController SIGABRT
【发布时间】:2013-03-23 16:16:03
【问题描述】:

我正在开发一个通用应用程序,当我尝试从

上的设备库中选择一张照片时

iPad 出现 SIGABRT 错误,但在 iPhone 上可以正常工作

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

提前感谢您的帮助!

【问题讨论】:

  • 你是如何实例化选择器的?
  • 两台设备都运行什么操作系统?
  • 请注意,您应该会在控制台中看到完整的错误消息。该错误清楚地说明了问题所在。

标签: iphone ios ipad sigabrt ios-universal-app


【解决方案1】:

请阅读UIImagePickerViewController 的文档:

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

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

您必须使用UIPopoverController 为 iPad 上的照片库提供图像选择器。

【讨论】:

    【解决方案2】:
            // 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];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-18
      • 2012-11-05
      • 2014-01-27
      • 2019-02-22
      • 1970-01-01
      相关资源
      最近更新 更多