【问题标题】:UITabBarController's TabBar blocking UIViewController that is pushed by UINavigationController it hostsUITabBarController 的 TabBar 阻止 UIViewController 由它托管的 UINavigationController 推送
【发布时间】:2025-12-02 20:05:01
【问题描述】:

我有一个有 5 个标签的 UITabBarController。每个都拥有一个 UINavigationController。

除了每次这些 UINavigationController 都推送一个 ViewController 之外,一切都运行良好。它们的底部被 UITabBar 挡住了。这是正常的。

但我想知道是否可以将 UIViewController 放在 UITabBar 上方?

知道怎么做吗?

编辑:

这是结构

UITabBarController
    Tab 0: UINavigationController
    Tab 1: UINavigationController
    Tab 2: UINavigationController
    Tab 3: UINavigationController
    Tab 4: UINavigationController

所以每次 NavigationController 推送一个 Uiviewcontroller。 UIViewController 的位置仍然被 UITabBar 挡住,因为它在它的下方。

如何在 TabBar 上方放置 UIViewController?

【问题讨论】:

  • 您能否提供一些屏幕截图或代码来帮助确定控制器的结构?
  • 您是使用故事板构建结构还是通过代码?您是否使用了自动布局以及如何通过 navCtrl 推送 VC?
  • 我不使用情节提要。纯代码。该行为是预期的。但我想知道是否有任何解决方法可以在 UITabBar 上方显示 ViewController
  • 你能看看我下面的答案是否有效吗?
  • 如果您希望它的行为如此,请隐藏标签栏或不使用来自 navCtrlr 的推送。我不确定你是否需要 navCtrlrs

标签: ios swift uinavigationcontroller uitabbarcontroller


【解决方案1】:

你能试试看是否有效吗?

destinationController.hidesBottomBarWhenPushed = true

在进入目标视图控制器之前执行此操作。

希望这会有所帮助。

【讨论】: