Search code examples
iosuinavigationcontrolleruitabbarcontrolleruitabbar

How to change UINavigationBar title without changing UITabBar title?


I have a UINavigationController embed on a UITabBarController. My goal would be to change the title of the UINavigationController's navigation bar while keeping the title on the UITabBarItem too. Tried changing the title of the UIViewController embed on the UINavigationController with:

self.title = @"NavBarTitle";

It does work, but that changes the UITabBarItem's title too. Is there a way to separate those two titles? Thanks!


Solution

  • try this

    self.navigationController.visibleViewController.title = @"NavBarTitle";
    

    or use

    self.navigationItem.title = @"NavBarTitle";
    

    or try this

    self.tabBarController.navigationItem.title = @"NavBarTitle";