如果我添加一个可以从 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/