【问题标题】:How to have multiple landscape views in Xcode 4.1.1如何在 Xcode 4.1.1 中拥有多个横向视图
【发布时间】:2012-08-18 17:51:06
【问题描述】:

好的,所以我想要 3 个视图,并且所有视图都是横向的,但我希望其中 2 个仅处于横向,并且我希望其中仅 1 个处于纵向。当我这样做时,他们都以肖像形式出现。我正在使用故事板。

我在 .m 文件中有:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeLeft)
        return YES;

    return NO;
}

我将它设置为目标和 plist 中的左侧横向,我有“初始界面方向”和“支持的方向横向左侧”。我已经尝试了所有方法,但没有任何效果,请有人帮助我。

【问题讨论】:

    标签: ios objective-c uiviewcontroller orientation landscape


    【解决方案1】:
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight);
    
    }
    

    将此添加到您希望在横向模式下拥有的每个视图控制器。希望这会对你有所帮助。

    【讨论】:

    • 我正在使用情节提要我应该怎么做?
    • 场景的实际显示方式不是由情节提要决定的,而是由视图控制器决定的。您需要创建一个 UIViewController 子类并实现 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation,仅当界面方向为横向时才返回 YES。
    猜你喜欢
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多