我目前在我的appDelegate中定义了我的导航控制器(代码汇总):
- (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;
}
我想在FlagListView的navigationBar中设置标题。但是,我希望能够在我的FlagList UITableViewController类的-viewDidLoad方法中执行此操作。我该如何访问这个属性?
我试过了:
[[self navigationItem] setTitle:@"Home"];
..但它似乎不起作用。有人可以告诉我我做错了吗?
答案 0 :(得分:1)
假设如果ViewController使用[self setTitle:@"Home"]
代替[[self navigationItem] setTitle:@"Home"];
答案 1 :(得分:0)
[self setTitle:@“Home”];
这应该有用。