[英]How to set the titles of different tabs in a UITabBarController?
我在TabBarApplication中具有以下標簽。 我從主頁導航到此TabBar。
UIViewController *viewController1 = [[ExpenseRecorderViewController alloc] initWithNibName:@"ExpenseRecorderViewController" bundle:nil];
UIViewController *viewController2 = [[TaxCalculatorViewController alloc] initWithNibName:@"TaxCalculatorViewController" bundle:nil];
UIViewController *viewController3 = [[CurrencyConverterViewController alloc] initWithNibName:@"CurrencyConverterViewController" bundle:nil];
UIViewController *viewController4 = [[emiCalculatorViewController alloc] initWithNibName:@"emiCalculatorViewController" bundle:nil];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,viewController3, viewController4, nil];
現在,如果我嘗試通過類似以下方法來設置這四個標簽的標題,
[[tabBarController.tabBar.items objectAtIndex:0] setTitle:@"title A"];
[[tabBarController.tabBar.items objectAtIndex:1] setTitle:@"title B"];
[[tabBarController.tabBar.items objectAtIndex:2] setTitle:@"title C"];
那就行不通了。 我想我需要在頂部設置導航欄的標題。 但是該怎么做呢?
應該這樣做:
appDelegate.newsNavController = [[[UINavigationController alloc] initWithRootViewController:newsViewController] autorelease];
appDelegate.newsNavController.navigationBar.tintColor = [UIColor blackColor];
appDelegate.newsNavController.tabBarItem.image = [UIImage imageNamed:@"IdCard.png"];
appDelegate.newsNavController.tabBarItem.title = NSLocalizedString(@"Title_News", @"");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.