gpt4 book ai didi

swift - 嵌套的导航 Controller 和 TabBar Controller

转载 作者:行者123 更新时间:2023-11-28 15:16:46 26 4
gpt4 key购买 nike

我的 Storyboard是这样的:

TabBarViewController
|-NavigationViewController
|-TableViewController

这有助于我在 TableViewController 中同时拥有导航栏和标签栏。

现在我尝试添加一个 SecondViewController 来显示表中所选项目的详细信息。所以我这样做了:

TabBarViewController
|-NavigationViewController
|-TableViewController
|-SecondViewController

但是SecondViewController不显示导航栏。所以我尝试了这个:

TabBarViewController
|-NavigationViewController
|-TableViewController
|-NavigationViewController
|-SecondViewController

但是SecondViewContrller中还是没有导航栏。我错过了什么?

最佳答案

我不完全确定您为什么需要这样的嵌套导航 Controller ?

请参阅下文,了解我认为是您想要的仅 Storyboard 解决方案,或者您可以创建自定义委托(delegate)来处理 View 堆栈和导航树。

我在这里假设您的“SecondViewController”是某种详细 View ?所以,像这样:

TabBarViewController
|-NavigationViewController
|-TableViewController (NavigationViewControllerDelegate)
|-DetailViewController (SecondViewController)

这是 Storyboard 解决方案(无代码):

  1. NavigationController 添加到 Storyboard
  2. 将它嵌入标签栏 Controller (从菜单中)
  3. 在 Storyabord 中添加一个 TableViewController
  4. 向表格 View 中的单元格添加按钮
  5. 将标准的 ViewController 添加到 Storyboard
  6. 将 tableview 单元格的按钮连接到新的 View Controller
  7. 向 Storyboard 添加另一个标准的 ViewController 并给它一个标签栏项
  8. 将标签栏 Controller 链接到这个 View Controller

然后你会得到这样的结果:

关于swift - 嵌套的导航 Controller 和 TabBar Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46716973/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com