为ViewControllers设置不同的条标题

时间:2017-05-18 10:29:16

标签: ios swift

我有一个带有NavigationController和TabController的viewController嵌入。(TabController设置为initialViewController)

我想更改导航栏的图块,但如果我更改一个viewController的标题,它将应用于所有ViewControllers。

如何为每个ViewController编写代码以使其具有不同的barTitle?

[Navigation Controller as initialViewController]

enter image description here

[![TabBarController as initialViewController] [2]] [2]

2 个答案:

答案 0 :(得分:3)

为此,您需要将所有Tabbar的ViewController嵌入NavigationController,所以现在每个viewController都有个人导航功能,并且很容易将标题设置为单个viewController和将UITabbarController设为ViewController的初始storyboard

所以你的结构应该像

TabbarController
    |->NavigationController1->ViewConctroller1
    |->NavigationController2->ViewConctroller2
    |->NavigationController3->ViewConctroller3
    |->NavigationController4->ViewConctroller3

查看下面的图片以获取更多参考资料:带有3个ViewControllers的TabbarController

enter image description here

答案 1 :(得分:2)

我认为这是Nirav所建议的正确方法。

enter image description here

在tabBarController中添加所需的视图控制器。现在将每个视图控制器嵌入到导航控制器中

相关问题