【问题标题】:xcode two uitabbarcontrollers one page. auto-rotate issuexcode 两个 uitabbarcontrollers 一页。自动旋转问题
【发布时间】:2012-01-07 01:18:04
【问题描述】:

夏天:

  1. 我有一个自定义的 UITabBarAutoRotateController,它从 shouldAutorotateToInterfaceOrientation 返回 YES。这没有任何效果。
  2. 如果我再次最小化并显示应用程序,轮播问题就会消失。
  3. 如何刷新屏幕以使用户不必执行此操作(这样旋转再次起作用)?

详情(以图形方式设置,因此无需代码):

我在 MainWindow.xib 中有两个 UITabBarController。我只想一次显示一个。所以我以图形方式链接 rootViewController = tabBarController_name1。还有tabBarController_name2。

我还将有一个警告消息框供用户选择他们需要的应用程序类型,它会根据他们的请求(根据客户定义)选择一个标签栏控制器。暂时将其注释掉。

当两个 UITabBarControllers 存在于同一个 xib 上时,旋转存在错误。当我尝试旋转屏幕时,无论主屏幕按钮(电源按钮查看按钮)朝向何处,它都会保持向上。 HandleOrientationChange 不会在显示的活动自定义 ViewController 上被调用。

我认为这是一个错误的原因是,如果我点击主屏幕按钮(最小化应用程序),然后单击应用程序(将其返回到前台),旋转效果很好!

很抱歉让你读了这么多废话:)。我真正的问题是,“无论如何我可以刷新主窗口或 UITabBarController 以使旋转工作(无需最小化和显示程序)”?如果您愿意,可以解决吗?

p.s. 出于向后兼容性的原因,我不能使用 Storyboard。客户将收到此代码/项目。所以我想把它保存在一个图形页面中,而不是隐藏/显示 UITabBarItem。

编辑:two-uitabbarcontrollers-and-autorotation 和 uitabbarcontrollers-and-uinavigationcontrollers 都有帮助,但没有解决“为什么”会发生这个问题。当涉及到 xcode 时,这里是“noob” :)

【问题讨论】:

  • 我现在的想法是使用 UINavigationController 并将导航面板隐藏在顶部(以便客户可以轻松地看到导航发生的位置)。每个 UITabViewController 将存在于单独的导航项下。我还在学习它的教程。这是解决这个问题的最佳方法吗?

标签: xcode uitabbarcontroller autorotate


【解决方案1】:

Tab bar controller inside a navigation controller, or sharing a navigation root view 就是答案。不要使用 TabBarViewController。其中,作为一个菜鸟,我不太清楚为什么 TabBarViewController 存在(或者至少没有贬值)。

将两个 TabBarViewController 拖到同一页面会导致警告说您可能希望通过制作自定义 UIViewController 并将普通 UITabBar 附加到它来实现 TabBarViewController。

令人沮丧...但终于取得了进展:)

【讨论】:

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