HI all
how can we set titles of tab bars programmatically.
i have five tabs in my main window.But i hvnt created it programmatically. what should i do ? how to give title through code?
regards shishir
HI all
how can we set titles of tab bars programmatically.
i have five tabs in my main window.But i hvnt created it programmatically. what should i do ? how to give title through code?
regards shishir
You can initialize and use a UITabBarItem object using the following functions:
- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag; // selected image autogenerated
- (id)initWithTabBarSystemItem:(UITabBarSystemItem)systemItem tag:(NSInteger)tag
And then you can call this method on your tabBar object:
- (void)setItems:(NSArray *)items animated:(BOOL)animated;
where items id the array to which you have added all your tabBarItem objects. There is also a badgeValue property for UITabBarItem if you need to use.
OR
[(UIViewController *)[tabBarController.viewControllers objectAtIndex:1] setTitle:@"Title1"];
Hey do you want to set the title of the tab bar button or the viewcontroller that is associated with the tab?
If you are looking for the first thing then do it like:
UITabBarItem *tabItem = [[[tabBarController tabBar] items] objectAtIndex:yourIndex];
[tabItem setTitle:@"theTitle"];
otherwise mihirpmehta
is correct.
Hope this helps.
Thanks,
Madhup