【问题标题】:How to show scene in landscape mode within xcode storyboard?如何在 xcode 故事板中以横向模式显示场景?
【发布时间】:2012-01-25 10:27:26
【问题描述】:

我在 xcode 中有故事板项目。大多数场景以纵向显示,但我想在不旋转设备的情况下以横向模式显示其中一个场景,始终显示此场景必须以横向显示。这个场景有一个带有 uiwebview 对象的简单视图控制器,我从 url 打开一个 pdf 文件。我的想法是将视图控制器显示为模态视图控制器。

有人知道如何解决这个问题吗?昨天我在网上搜索了这个问题,但我没有找到解决方案。

提前谢谢你!

【问题讨论】:

    标签: iphone xcode uiwebview landscape-portrait xcode-storyboard


    【解决方案1】:

    场景的实际显示方式不是由情节提要决定的,而是由视图控制器决定的。您需要创建一个UIViewController 子类并实现- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 以仅在界面方向为横向时返回YES。你可以这样做:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    

    允许两个方向或替换为

    return interfaceOrientation == UIInterfaceOrientationLandscapeLeft
    

    只允许一个方向。

    【讨论】:

    • 谢谢...我添加了代码并更改了 uiwebview 的尺寸,完美!,工作正常!...
    猜你喜欢
    • 1970-01-01
    • 2018-04-21
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    • 2014-09-29
    • 2015-12-13
    相关资源
    最近更新 更多