使用Photolibrary将shouldAutorotate设置为false [英] Set shouldAutorotate to false with Photolibrary

查看:161
本文介绍了使用Photolibrary将shouldAutorotate设置为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我添加了一个弹出式窗口,可以从iPad访问我的相册,则系统始终会崩溃,并显示以下消息:

If I add a popover with access to my photo gallery from the iPad the system always crash with the following message:

由于未捕获的异常'UIApplicationInvalidInterfaceOrientation',终止了应用程序,原因:支持的方向与应用程序没有共同的方向,并且[PUUIAlbumListViewController shouldAutorotate]返回YES"

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

但是我已经在我的项目信息中设置了仅用于支持横向模式.

But I already set up in my Projekt Information just to support Landscape Mode.

所以我添加了以下功能

override func shouldAutorotate() -> Bool {

    return false
}

但是我不知道如何使用它?如果我也启用了我的应用程序上的UIInterfaceOrientationPortrait,它就可以正常工作.但是我不想支持UIInterfaceOrientationPortrait.

But I don't know how to use it? If I enable UIInterfaceOrientationPortrait on my app too, it works fine. But I don't want to support UIInterfaceOrientationPortrait.

我将这样称呼我的弹出窗口:

I'll call my popover like this:

var popover: UIPopoverController = UIPopoverController(contentViewController: ImagePickerController)

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

任何帮助将不胜感激

推荐答案

您别无选择.实际上,您已经解决了问题.正如您已经说过的,解决方案是在您的应用程序中启用纵向方向.您不必在其他任何视图控制器中使用它,但是必须将其包括在应用程序的允许方向中,因为您要显示的该一个视图控制器需要它.如果视图控制器要求与应用程序允许的交集之间的交集为空,则应用程序将崩溃(如您所见).

You have no choice. And in fact you have solved the problem already. As you have already said, the solution is to enable portrait orientation in your app. You don't have to use it in any of your other view controllers, but you must include it in the app's permissible orientations, because this one view controller that you are trying to show requires it. If the intersection between what the view controller requires and what the app permits is null, the app will crash (as you have seen).

这篇关于使用Photolibrary将shouldAutorotate设置为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆