6

I have a tabbar controller in my iphone app. Everything was fine until the second tabbar item is clicked. When its clicked, the tabbaritem title/name under the tabbar icon for the second tab will disappeared. But there's no problem with the first tab.

Do anybody knows whats the reason for this.

sicKo
  • 1,241
  • 1
  • 12
  • 35

3 Answers3

14

It may be the problem with the view controller in the second tab bar item. Have you used the title inside of the view controller of the second tab bar item. If no then try using title of the view controller to the name/title of the second tab bar item. I hope this should solve the issue.

Sandeep
  • 20,908
  • 7
  • 66
  • 106
  • Please elaborate on this "Have you used the title inside of the view controller of the second tab bar item." - thanks – Seb Kade May 29 '11 at 10:38
  • 1
    @Seb Kade: self.title = @"title"; in seconds view controller. – Mahesh Jun 06 '11 at 10:38
  • I was having a similar case but this solution didn't worked. This code in viewDidDisappear of same class worked for me [[self.tabBarController.tabBar.items objectAtIndex:2] setTitle:@"Chat"]; – NaXir Mar 08 '16 at 09:23
  • 2
    It worked, Make sure you didnt set self.title = "" in a view controller whose tabbar item name is missing – Abdul Waheed Jun 30 '20 at 16:31
1

In my case, the title was being set correctly but the color of the title was in "clear color" when selected.

Solution:

In AppDelegate.m

[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor blackColor] }
                                         forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor redColor] }
                                         forState:UIControlStateSelected];
Taku
  • 5,639
  • 2
  • 42
  • 31
0

deleting the title did the trick for me from the viewController. my setup was to create a UITabBarController that actually shows in other storyboards by doing storyboard references from the main storyboard so i just dragged from the UITabBarController to to the storyboard reference -> double click on the storyboard reference to open the other storyboard -> add tabBarItem to the viewController -> deleted the title from that viewController in code => works great

YB88
  • 3
  • 2