1

I'm confusing.

All I want to do is setting title "one" to the viewcontroller and title "two" to the tab bar item that show it.

What happen now is : I set "one" to the tabbaritem in Interface builder. When I set in the viewDidLoad self.title="two", the tab bar item text is changed also to "two"

How can I prevent that ?

Thanks.

toliron
  • 13
  • 3
  • 2
    Chek out [this answer](http://stackoverflow.com/questions/1540718/self-title-sets-navigationcontroller-and-tabbaritems-title-why/1596277#1596277) in case it helps. – albertamg Jul 31 '11 at 11:24

3 Answers3

17

You can use self.navigationItem.title.

TonyTony
  • 1,344
  • 15
  • 23
5

In a normal UIViewController, self.title refers to the same object as self.tabBarItem.title. You can't change them independently.

If you want to display a title somewhere other than in the UITabBarItem, you could add a UILabel to the view and set its text.

Phssthpok
  • 1,629
  • 1
  • 14
  • 21
2
[[self.tabBarController.tabBar.items objectAtIndex:idx] setTitle:@"text"];
Tunaki
  • 132,869
  • 46
  • 340
  • 423
Postolaki
  • 41
  • 2
  • 3