Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set title of tab bars programmatically

Tags:

tabs

iphone

I have five tabs in my main window, but I haven't created it programmatically.

What should I do to create the title through code?

like image 597
Shishir.bobby Avatar asked Jun 17 '10 09:06

Shishir.bobby


2 Answers

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.

like image 60
Madhup Singh Yadav Avatar answered Oct 14 '22 23:10

Madhup Singh Yadav


OR

[(UIViewController *)[tabBarController.viewControllers objectAtIndex:1] setTitle:@"Title1"];
like image 37
Mihir Mehta Avatar answered Oct 14 '22 21:10

Mihir Mehta