【问题标题】:orientation support in TabBar application for iphone storyboardiphone 故事板的 TabBar 应用程序中的方向支持
【发布时间】:2012-10-18 06:23:10
【问题描述】:

我正在创建具有 4 个选项卡的 Tabbar 应用程序,我的 FirstTabView 应该支持所有方向,所有 3 个 tabView 应该只支持纵向,当我将选项卡更改为 SecondTabView 时,它应该强制将方向更改为纵向,这在情节提要中是否可行我将以下代码用于 FirstTabView.m

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

在 SecondTabView.m 中

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

它不允许任何选项卡视图支持横向提前感谢。

【问题讨论】:

    标签: iphone ios5 xcode4


    【解决方案1】:

    在 iOS 5 或更早版本上,每个相应选项卡的 viewController 必须从 shouldAutorotateToInterfaceOrientation 返回 YES 以使 tabBarController 自动旋转,而不仅仅是当前可见的。

    【讨论】:

      【解决方案2】:

      是的。故事板是可能的。为此,您需要检查选择了哪个选项卡。您可以使用检查它

      - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController;
      

      在其中应用您想要定向的第一个视图控制器的条件。在那里设置您的方向或将其应用到单独的视图控制器中。

      享受编程。

      【讨论】:

      【解决方案3】:

      如果您在 iOS6 上遇到此问题 在 iOS6 中,Apple 已经改变了管理设备方向的方式。Apple 在其文档中引入了许多新方法。在其文档中所做的更改之一是

       - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      

      苹果已经在iOS6版本中弃用了这个方法。所以这个方法可以从苹果文档中删除。如果你想管理设备方向。那么你应该实现iOS6中引入的新方法。你应该看看 iOS6 版本中所做的更改。 link

      我发布了一段代码,你可以试试。很容易实现。

      Please go through this Link

      我认为它可以帮助你。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多