【问题标题】:xcode navigating from Portrait View to Landscape Viewxcode 从纵向视图导航到横向视图
【发布时间】:2012-08-27 06:26:51
【问题描述】:

我有一个简单的 ios 导航应用程序。我的问题是在只允许以纵向显示的 viewController 和必须以横向显示的 viewController 之间导航。

问题是第二个 viewController 在加载时不会显示在 Landscape 中。如果我旋转设备,它会按原样更新,但我希望因为它只支持横向而不是在首先转换到视图时自动捕捉到横向。有什么想法吗?

谢谢

【问题讨论】:

    标签: iphone ios xcode ipad orientation


    【解决方案1】:

    你应该实现shouldAutorotateToFaceInterfaceOrientation:

    把这个放在 PortraitviewController.m 中:

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

    这在 LandscapeviewController.m 中:

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

    【讨论】:

    • 我已经有这个了。这似乎对问题没有任何影响。
    • 该函数应该在视图加载时被调用,它被调用了吗?检查 NSLog 或断点
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 2012-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多