checkmate711
checkmate711

Reputation: 3461

Setting a Title in iOS

I'm using iOS 5 with storyboards. I have a root Navigation Controller and attached to that a Tab Bar Controller with two Tab Bar Items. I'm trying to manually or programmatically set the title in one of the Tab Bar items on the top navigation bar.

Below are some of the fun things I tried in ViewDidLoad but the title is still not showing up.

self.navigationController.navigationItem.title = @"Item List";
self.navigationItem.title = @"Item List";
self.tabBarItem.title = @"Item List";
[self.tabBarItem setTitle: @"Item List"];
[self.navigationItem setTitle:@"Item List"];
[[self.parentViewController.tabBarController.tabBar.items objectAtIndex:0] setTitle: @"Item List"]; 

How do you set the title in iOS 5?

Upvotes: 0

Views: 119

Answers (2)

checkmate711
checkmate711

Reputation: 3461

Thanks for all your comments. I found the correct statement is

self.tabBarController.navigationItem.title = @"Item List";

called in ViewDidLoad.

Upvotes: 0

Edwin Iskandar
Edwin Iskandar

Reputation: 4119

Did you try self.title = @"Item List"? :)

-(void) viewDidLoad {
    [super viewDidLoad];
    self.title = @"Item List";
}

Upvotes: 4

Related Questions