开发者

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];

    tabBa开发者_运维百科rController.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?


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


[self setTitle:@"Home"];

This should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜