0

I have a simple question (maybe not a simple answer). Currently I have an iPhone app and I tab bar and navigation set up on it. When I set the self.title it puts it in both the tab bar and the navigation bar. I was wondering if there was a way to have a different title on the navigation bar and tab bar?

Peter
  • 1
  • Take a look at this link:http://stackoverflow.com/questions/1540718/self-title-sets-navigationcontroller-and-tabbaritems-title-why/1596277#1596277 – ms83 Sep 12 '11 at 22:48

3 Answers3

1

You're setting the title of the whole view, which in turn automatically sets the title of the tabBar and the nav controller. To set the title of them each individually, You first set the nav bar by accessing the nav item:

[[self navigationItem] setTitle:(NSString *)];

Then you set the tabBar title by accessing the tab bar item and setting its title like so:

[self.tabBarItem setTitle:(NSString *)];

Good Luck!

Kyle Rosenbluth
  • 1,672
  • 4
  • 22
  • 38
0

use self.navigationItem.title for the navigation bar.

Jesse Naugher
  • 9,780
  • 1
  • 41
  • 56
0

This is a common mistake and happened to me so many times.

To get around this, every ViewController comes with a navigationItem property giving you even further options.

Use following line inside your ViewControllers to set the title:

self.navigationItem.title = @"Your Desired Title";
Faizan S.
  • 8,634
  • 8
  • 34
  • 63