Reputation: 52337
I have a UITabBarController in which the first UITabBarItem title is not getting displayed. I have it set in Interface Builder and have tried to set it programmatically, but the title area stays blank.
[[tabBarController.tabBar.items objectAtIndex:0] setTitle:@"Test1"];
[[tabBarController.tabBar.items objectAtIndex:1] setTitle:@"Test2"];
(The Item 2 is set through Interface Builder, which is where that title is coming from, just to test that the IB titles are working as well -- except for the first one)
I have a feeling this is the odd result of adding the UITabController to the project and dragging the existing view into the first spot, but don't know how to fix it.
Here's the view in Interface Builder:
Moving the ViewController that's in the first spot to the second spot yields the result you'd expect -- the second spot becomes blank and the first gets set with "Test1", meaning it's not something funny with just the first spot.
Upvotes: 2
Views: 2296
Reputation: 41
Just go to your init method in your view controller's .m file and in order to set the tab bar item's title use:
[[self tabBarItem] setTitle:@"Main"];
and for setting its image, use:
[[self tabBarItem] setImage:[UIImage imageNamed:@"SomeFilename.png"]];
Upvotes: 4
Reputation: 2199
type [self setTitle:@"Title"]
in your viewcontroller for the first view instead of declaring it through the viewcontrollers array. don't know whats wrong though, but I had to do this once
Upvotes: 3