2
votes

I am using a UITabBar whose first tab relates to a UINavigationController. The UINavigationController's root view controller's viewWillAppear: sets that view controller's (and hence the navigation controller's) title to the current month symbol. This implicitly also changes the title shown in the tab bar.

How can I achieve an alternative situation where the tab bar shows a static title (e.g. "Calendar") whereas its related navigation controller still shows the dynamic one (e.g. "December")?

enter image description here

1

1 Answers

0
votes

The following solution now works for me. MonthViewController is the UINavigationControllers root view controller.

class MonthViewController: UIViewController {

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)

        // calculate monthSymbol ...

        self.title = monthSymbol

        let tabBarController = self.navigationController!.parentViewController as! UITabBarController
        tabBarController.tabBar.items![0].title = "Calendar"
    }
}