ios - 使用 Photolibrary 将 shouldAutorotate 设置为 false

标签 ios swift uipopovercontroller uiinterfaceorientation shouldautorotate

如果我添加一个可以从 iPad 访问我的照片库的弹出窗口,系统总是会崩溃并显示以下消息:

Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'

但我已经在我的 Projekt Information 中进行了设置以支持横向模式。

所以我添加了下面的函数

override func shouldAutorotate() -> Bool {

    return false
}

但是不知道怎么用?如果我也在我的应用程序上启用 UIInterfaceOrientationPortrait,它工作正常。但我不想支持 UIInterfaceOrientationPortrait

我会这样称呼我的弹出框:

var popover: UIPopoverController = UIPopoverController(contentViewController: ImagePickerController)

popover.presentPopoverFromBarButtonItem(addImageButton, 
                                        permittedArrowDirections: UIPopoverArrowDirection.Any, 
                                        animated: true)

任何帮助将不胜感激

最佳答案

你别无选择。事实上你已经解决了这个问题。正如您已经说过的,解决方案是在您的应用程序中启用纵向。您不必在任何其他 View Controller 中使用它,但您必须将它包含在应用程序允许的方向中,因为您试图显示的这个 View Controller 需要它。如果 View Controller 要求的内容和应用程序允许的内容之间的交集为空,应用程序将崩溃(如您所见)。

关于ios - 使用 Photolibrary 将 shouldAutorotate 设置为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25090167/

相关文章:

ios - Pinterest SDK : "PDKClient not found", 出了什么问题?

ios - IGListKit 从 Alamofire 请求向类插入数据

ios - 仅横向的 iPad 应用程序以纵向显示 UIImagePicker

ios - UIView 默认样式有圆角?

ios - 在 Swift 中实现 PageViewController

ios - 如何从本地路径加载图像 ios swift(按路径)

ios - Xcode Swift 计算 23 个文本字段值的平均值

ios - CoreData + Codable 不保存

ios - Swift 从 UITableView 呈现弹出窗口运行速度非常慢

ios - UIActivity ActivityViewController 在 Swift 中的 iPad 上崩溃