dpigera
dpigera

Reputation: 3369

Setting a navigationBar title

I currently have my navigation controllers defined in my appDelegate as followed (code summarized):

- (void) applicationDidFinishLaunching {
tabBarController = [[UITabBarController alloc] init];

    FlagList *flagList = [[FlagList alloc] initWithApiCall:API_PUBLICTIMELINE andTitle:@"Home"];

    UITabBarItem *homeTab = [[UITabBarItem alloc] initWithTitle:@"Home" 
                                                          image:[UIImage imageNamed:@"home.png"] 
                                                            tag:0];
    flagList.tabBarItem=homeTab;
    [homeTab release];

    tabBarController.viewControllers=[NSArray arrayWithObjects:flagList,nil];
    [flagList release];


    [rootViewController release];
    rootViewController = [[UINavigationController alloc] initWithRootViewController:[tabBarController autorelease]];
    rootViewController.navigationBar.barStyle=UIBarStyleDefault;
}

I want to set a title in the navigationBar of my FlagListView. HOWEVER, I want to be able to do this in the -viewDidLoad method of my FlagList UITableViewController class. How can I access this property?

I tried:

[[self navigationItem] setTitle:@"Home"];

..but it doesn't seem to work. Can someone please tell me what I'm doing wrong?

Upvotes: 0

Views: 585

Answers (2)

Roshan Amadoru
Roshan Amadoru

Reputation: 365

[self setTitle:@"Home"];

This should work.

Upvotes: 0

codelark
codelark

Reputation: 12334

Assuming FlagList is a descendant if ViewController use [self setTitle:@"Home"] instead of [[self navigationItem] setTitle:@"Home"];

Upvotes: 1

Related Questions