7
votes

In my app I have embedded a UITabBarController inside of my UINavigationController. The problem is that the UINavigationController treats that tab bar as a single view controller even though there are 4 tabs in it. I am needing to have a different header title for each of those 4 tabs that displays in the navigation bar header. Using self.title on a subclass for those 4 views does nothing. It just displays the same title in the navigation bar constantly because like I said, the UINavigationController treats that entire tab bar controller as a single view.

How can I have separate titles for each of my views that are tabs inside the tab bar controller?

2

2 Answers

11
votes

Try using [self.navigationItem setTitle:] inside each tab's view controller. If this does not work, try deeper, [self.tabBarController.navigationItem setTitle:].

5
votes

Looks quite straight forward.

Set a UITabBarDelegate as your UITabBarController subclass and implement the delegate method -

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item

Inside this method set the respective title based on the tab selected. It should work!