Does Self.title set the navigation of the Controller and the tabBarItem header? What for?

I do this in a UIViewController for one of my tabs:

self.title = @"Welcome"; 

However, it overwrites everything I have for tabBarItem. I tried:

 self.tabBarItem.title = @"Home"; 

and

 [self.tabBarItem initWithTitle:@"Home" image:[UIImage imageNamed:@"iconHome.png"] tag:0]; 

But still self.title overwrites tabBarItem, regardless of whether I try to use the last two code snippets after the header has been set. The code even works without errors, but self.tabBarItem.title or initWithTitle do nothing?

+55
iphone uinavigationcontroller
Oct 08 '09 at 21:53
source share
4 answers

OK, I get it! That's what I'm doing:

 self.title = @"Title for TabBarItem"; // TabBarItem.title inherits the viewController self.title self.navigationItem.title = @"Title for NavigationBar"; 

the navigationBar inherits self.title unless otherwise set using self.navigationItem.title

+160
Oct 20 '09 at 17:54
source share
 //set nav item title self.navigationController.navigationBar.topItem.title = @"zurΓΌck"; 

it did it for me: =) (none of this was done)

+51
Mar 14 '11 at 12:28
source share

Try:

 [self setTitle:@"Welcome"]; UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"Home" image:[UIImage imageNamed: image] tag:0]; [self setTabBarItem:item]; [item release]; 
0
Oct 08 '09 at 22:17
source share

I also ran into the same problem, but I solved this problem as follows. I set the title and image of the tabBarItem right after I created them in appDelegate.

This is what I did:

 [viewController setTitle:@"controllerTitle"]; [[viewController tabBarItem] setTitle:@"Custome Title for tab"]; [[viewController tabBarItem] setImage:[UIImage imageNamed:@"tab.png"]]; 
0
Aug 30 '10 at 17:41
source share



All Articles