【问题标题】:Show UITabBar on UIViewControllers that are not part of the UITabBar?在不属于 UITabBar 的 UIViewControllers 上显示 UITabBar?
【发布时间】:2018-11-04 20:45:07
【问题描述】:

我有一个用 Swift 编写的 iOS 应用程序,带有 UITabBarController 和 5 UIViewControllers。现在,我有一堆不属于UITabBarControllerUIViewControllers。我希望能够显示相同的标签栏,但我不知道该怎么做。有什么线索吗?

更多细节:这是标签栏拥有的视图控制器之一。我使用故事板引用并将我的视图控制器拆分为单独的更易于管理的故事板。

所以,大局:

没有初始 ViewController,因为我使用 storyboardId 来访问初始导航控制器。从那里我们在同一个导航控制器中嵌入了一个 ViewController。 In that ViewController, there are 2 Container views - one of the size of the bottom ViewController that contains the "hamburger" button that toggles the other Container View which has an embedded UITableView in. When a specific cell is selected it should go to Profile ViewController这甚至不在同一个故事板中。 segue 设置为 Push。无论哪种方式,都不会在 Profile ViewController 上显示 UITabBar

【问题讨论】:

  • 你如何展示/展示其他UIViewControllers?如果它们被推送到属于UITabBarController 层次结构的UINavigationController,那么标签栏应该是可见的。
  • 嗯,这取决于但我将整个项目分成许多故事板并通过故事板参考连接。所以,segue 可以是我想的任何东西
  • 好吧,正如我所说,例如,如果您的一个 UITabBarController 有一个 UINavigationController 作为它的项目之一,每当您在它的堆栈上推送一个新的 UIViewController 时,标签栏就会保持原位.如果您以模态方式呈现它,标签栏将被隐藏。
  • @MihaiFratu 我认为我做错了什么,因为它不起作用。我在帖子本身中添加了更多细节和一些屏幕截图。你能看一下吗?

标签: swift xcode uiviewcontroller uitabbarcontroller


【解决方案1】:

你好吗? 我不知道我是否理解,但是您在转到另一个屏幕后试图显示标签栏,对吗?如果答案是“是”,请尝试将您的 segue 更改为 show(e.g. push)

-----编辑-----

您可以通过两种方式进行:

  1. 模态呈现 -> 使用当前上下文

  1. 使用push(e.g.)navigation view controller,如果你去Navigation controller -> Attributes inspector -> Navigation Controller -> Uncheck Shows Navigation Bar也可以隐藏导航栏

希望现在它可以工作了! 最好的问候

【讨论】:

  • 你正确地理解了我,是的。但是 segue 已经设置为 Show (e.g. push) 并且它不起作用。
  • 检查你的 ViewController 中是否勾选了“hide Bottom Bar on push”选项
  • 是的,检查过了
  • 如果选中“在推送时隐藏底部栏”,请尝试取消选中
  • 默认不勾选。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-03
  • 2021-02-12
  • 1970-01-01
  • 1970-01-01
  • 2011-08-16
相关资源
最近更新 更多