6

How can I modify the title and the icon of items of TabBarController? It is possible directly in Interface Builder?

Reda
  • 1,277
  • 1
  • 13
  • 27
  • Yes, you can do it programetically as well directly from IB too.I suggest you to start a New Project of type Tabbed Application in XCode. You'll get your answer. – Hemang Mar 17 '12 at 09:12
  • I have already a TabBarController, and when i add a segue, i can see a tab bar item created but i can't select it – Reda Mar 17 '12 at 09:19
  • i'm trying to do that in IB, i don't have code – Reda Mar 17 '12 at 09:32

1 Answers1

13

in code:

UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Fancy Tab" image:[UIImage imageNamed:@"FancyTab"] tag:1];
myViewController.tabBarItem = tabBarItem; // to set the tabBarItem from outside the viewController
self.tabBarItem = tabBarItem;             // to set the tabBarItem from inside the viewController

in regular .xib: click the item in the tabBarController. And then click it again. You can now edit title and icon in the attribute inspector.

in storyboard: click the item in the viewController that is connected to the tabBarController (not in the tabBarController itself). This time one click is enough. And set title and icon in the attribute inspector.

enter image description here

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
  • I use storyboard, and the problem is that i can see in IB when i add a segue, but in the left in IB, there is no items created under the tabBar – Reda Mar 17 '12 at 09:32
  • did you add the correct segue? It has to be "Relationship - View Controllers" – Matthias Bauch Mar 17 '12 at 09:45
  • strange. So your storyboard doesn't look like the one in my screenshot? Did you change "Simulated Metrics" - "Bottom Bar" of the view controller in the attributes panel? – Matthias Bauch Mar 17 '12 at 10:31
  • I was trying to edit the item in the TabBarController, thanks a lot – Reda Mar 17 '12 at 12:33