【问题标题】:XCODE Storyboards, landscape viewXCODE 故事板,横向视图
【发布时间】:2012-05-06 21:12:39
【问题描述】:

我使用 Storyboards 创建了一个应用程序,并将其设计为横向的。

在视图 controller.m 文件中,我放置了以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
        (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

我也尝试了该代码的一百万种变体,结果都相同。

此外,我在 info.plist 中更改了支持的方向,当然也制作了情节提要横向。但是,当我模拟时,最初的启动是横向的,然后子导航窗口会恢复为纵向。所以,我的问题是,如何在使用情节提要时覆盖肖像默认值(意思是,没有笔尖)?我是制作应用程序的新手——所以对于你们和你们的大脑来说,这可能是一件非常简单的事情,所以我认为这值得一问。我准备好接受你的笑声和对我新手行为的指指点点。 =]

【问题讨论】:

    标签: xcode nib landscape


    【解决方案1】:

    您是否将您的自定义控制器类(您在其中覆盖了 shouldAutorotateToInterfaceOrientation 方法)与情节提要中的场景相关联?如果不是,您需要确保在情节提要编辑器中场景身份检查器的自定义类部分中引用了此类。

    我喜欢在 shouldAutorotateToInterfaceOrientation 方法中使用这条指令来确保只支持横向:

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

    你可以看看这个教程作为ios5故事板的介绍:http://blogs.interknowlogy.com/2012/01/16/introduction-to-ios-5-storyboards-part-1/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      • 1970-01-01
      • 2012-05-02
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 2012-04-10
      相关资源
      最近更新 更多