I'd like to be able to give my views short names for display on the tab bar, and longer (more descriptive) name when the same view is linked to in a table view. The reason is that longer names nudge up against each other on the tab bar. In a table view, there's more horizontal space, so I want to use more descriptive titles there.
Normally, the tab bar's title is set in its view controller with self.title
. Is there a way to specifically set the tab bar title, but leave the view controller's self.title
alone?
Thanks.
The information that is displayed in a UITabBar is queried from each UIViewController's tabBarItem" property. Similarly, a UINavigationBar queries the UIViewController's navigationItem for information.
Setting two different titles would work like this (from within you UIViewController):
self.tabBarItem.title = @"TabTitle";
self.navigationItem.title = @"NavigationTitle";
You can also specify other details like the tab bar image or the title on the "back button" via these properties.
Short and sweet, in your view controller's viewDidLoad
:
[[self tabBarItem] setTitle:@"Short Title"];
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