Question

I have a UINavigationController and UITabBarController visible at the same time. Both the tab bar buttons and the navigation bar take their text from the title of the currently active view.

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"View Title";

However I want the different. In fact I'd like the navigation controller title to remain the same whichever view is being displayed.

Any ideas?

Many thanks.

Was it helpful?

Solution

You'll have to manually assign the title name, as you are doing above, in your other view controllers.

If your view hierarchy is more than two levels deep, be wary as the back button will look a little strange to the user (unless you override it). In fact, if every view has the same title, that may look strange to the user, period...

OTHER TIPS

Try This

UITabBarItem *tItem = [self tabBarItem];
[tItem setTitle:@"Title for tabbar"];

it won't change your tabbar title when you set the navigation title like

[self setTitle:@"Title for navBar"];

but I found sometimes it changes both tabBar and naviBar

then I insert the TabBar set titling code in -(void)viewWillAppear again to prevent such happening

Thanks

   -(void)viewDidLoad{
 [self setTitle:@"Custom Title goes here"];
}

This worked for me.

According to KwangBok Lee, I have tested, the best answer would be:

self.title = @"my settings";//changes both tabbars and navigationbars title

self.tabBarItem.title = @"settings";//only changes tabbars title

What I've found is... using

self.tabBarController.title = @"navTitle";

changes the navigation bar title, while

self.title = @"tabTitle";

changes the tab bar item title.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top