ios - Ipad 照片选择器

标签 ios xcode ipad

我正在尝试让 IPAD 从相册中选择一张照片

            pickerController = [ [ UIImagePickerController alloc ] init ] ;
            pickerController.delegate   = self ;
            pickerController.editing    = NO ;
            pickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

            [ self presentViewController : pickerController animated : YES completion : nil ] ;

当我在 iPad 上使用时,该应用程序不断崩溃,但在 iPhone 上运行良好。

最佳答案

这个以前也有过我。在 iPad 上,如果您指定源类型 UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerControllerSourceTypeSavedPhotoAlbum您需要使用弹出框 Controller 呈现图像选择器 Controller 。如果你尝试以模态方式呈现它,就像你正在做的那样,你会得到一个异常(exception)。

不是 100% 需要,但使用测试查看可用的源类型也是一个好主意。

[UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]

源类型有:
  • UIImagePickerControllerSourceTypePhotoLibrary
  • UIImagePickerControllerSourceTypeSavedPhotosAlbum
  • UIImagePickerControllerSourceTypeCamera

  • 这就是我解决这个问题以测试它是否是 iPad 的方法。
    if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
    
        UIPopoverController* popOverController = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
        [popOverController presentPopoverFromRect:selectVideoToViewButton.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    
    }else {
        [self presentModalViewController:self.imagePickerController animated:YES];
    }
    

    关于ios - Ipad 照片选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11787828/

    相关文章:

    javascript - 如何在 UIWebView 中将数据从 Xcode 传递到 javascript?

    ios - 在 tableView 中下载图像(_ :, cellForRowAt :)

    iphone - iOS 应用程序为调用添加前缀

    ios - 在另一个 uiimage 之上创建图像

    ios - 无法在 iOS 应用程序中启动 native Google map - 而是打开 Safari

    ios - View Controller 状态栏在像 ios 8 这样的新 iPhone 中重叠

    ios - SpriteKit 中的 ScrollView

    javascript - 在 iPad 上使用 touchmove 移动图像(css3 变换)

    javascript - 使用 jQuery 检测 iPad 用户?

    ios - iOS 编程支持的实时视频流格式