我发现很多文章,当谷歌搜索这个,但没有一个似乎真的覆盖这种情况下,所以我会尽量做到非常具体。 我有适用于iPhone和iPad的Landscape only应用程序。我试图让用户从他的专辑中挑选其他图片用下面的代码:UIImagePickerController只从横向选择iPhone/iPad应用程序
let imagePicker = UIImagePickerController()
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
imagePicker.mediaTypes = [kUTTypeImage as String]
imagePicker.modalPresentationStyle = UIModalPresentationStyle.Popover
imagePicker.allowsEditing = false
context.presentViewController(imagePicker, animated: true, completion: {
() -> Void in
})
我现在用的是酥料饼的表现风格,因为Apple mentions是在iPad上,这是应该怎样设置否则将引发异常:
该表显示,在iPad上,如果指定 photoLibrary或savedPhotosAlbum的源类型,则必须使用酥料饼的控制器出现在图像拾取 (学习如何做到这一点,看到 UIPopoverPresentationController)。如果您试图以模式(全屏)方式显示图像 以便在保存的图片和 电影中进行选择,系统会引发异常。
这失败,下面的错误
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'
我曾尝试:
- 子类的UIImagePickerController和UIViewController的支持横向方向,并设置shouldAutorotate假的,但我觉得这是没用的因为在这里失败的类是PUUIAlbumListViewController
- 设置我的应用程序支持肖像,这个工程,但然后整个应用程序aut与手机otorates,这并不意味着要发生
- 使用中间UIPopoverPresentationController,但从来没有得到这说明了什么
UPDATE 不是一个答案,但疯狂的,因为它看起来我不认为这是可行的。感谢苹果提供了一切皆有道理的最先进的API。 我结束了使用DKImagePickerController,完成这项工作