I have 9 tabs in my tabbar... And I want to change the title of all of them from some view controller. and I did it as follows:
for (int i=0; i(less than)[appDelegate.tabBarController.viewControllers count]; i++) {
UIViewController *uv=[appDelegate.tabBarController.viewControllers objectAtIndex:i];
uv.tabBarItem.title=@"test";
}
It changes the title for all visible tabs instantly but not working for tabs in more...
However if I click on edit button in more nav cntrl it shows changed name.
Also... very strange... If I select some tab in more then all the tabs reflects new name
why is it so???
Changing the title of a UIBarItem (superclass of UITabBarItem) needs to be done before the item is added to a bar per Apple docs. Looks like iOS is caching the titles once the items are added to the bar so you're getting unpredictable behavior.
From the UIBarItem Class Reference:
title
The title displayed on the item.
@property(nonatomic, copy) NSString *title
Discussion
You should set this property before adding the item to a bar. The default value is nil.
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