In my iPhone application, I have a tab bar. This tab bar holds a UINavigationController. I have:
self.tabBarItem.title = 'Create New';
and self.title = 'Create New';
self.title = 'Blah';
.But, always, the self.title of the first view controller pushed onto the navigation controller is shown (Blah). How would you set the title of the tab bar item? Thanks, Isaac Waller
I found if I used self.navigationItem.title = 'Blah';
instead of self.title
, it would work.
I just solved the same issue. I was using self.tabBarItem.item
for the 1st tab of my tabBarController
, which is the first and only one that loads its navigationController
. So for the first tab in a tab bar you have to set the title differently. I'll try to illustrate:
tab bar with 3 tabs (a UINavigationController
provides content each tab)
self.tabBarItem.item
to '1st') self.title
to 'tab1 View'self.tabBarItem.item
to '2nd') self.title
to 'tab View'self.tabBarItem.item
to '3rd') self.title
to 'tab3 View'When the tab bar loads all of its viewControllers
for each of the 3 tabs, the tab buttons in the tab bar have these labels:
This is because the 2nd and 3rd nav controllers aren't loaded until the user selects those tabs. The 1st tab is loaded when the UITabBarController
is loaded and due to the order of events it replaces the tabBarItem.title
with the navController's rootViewController's self.title
.
To fix this, you simply use self.navigationItem.title
instead of self.title
. You ONLY have to do this for the 1st tab's navController's rootViewController.
I hope that makes sense. You did solve your own problem, but I wanted you and anyone else to know WHY it works like this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With