简体   繁体   English

标签栏控制器..项目标题

[英]Tab Bar Controller .. Item Title

i have 3 Items in my TabBar, and i will load a saved Title for this Items... 我的TabBar中有3个项目,并且我将为此项目加载一个已保存的标题...

this works with this Code in ViewDidLoad.. 这适用于ViewDidLoad中的此代码。

  NSString *loadstring = [defaults objectForKey:@"char1_class"];
                NSString *charleveltitel = [defaults objectForKey:@"char1_class_level"];


                NSString *titel = [NSString stringWithFormat:@"%@ %@", loadstring, charleveltitel];
                self.navigationItem.title =  titel ;


                [[self.tabBarController.tabBar.items objectAtIndex:0] setTitle:NSLocalizedString(titel, @"comment")];

but... only when i click on the Bar Item... the code Starts in the ViewDidLoad... 但是...仅当我单击Bar Item时...代码才在ViewDidLoad中启动...

i will load this for all Tabs by start the App... 我将通过启动应用程序为所有选项卡加载此选项...

Thanks Jürgen 谢谢于尔根

If you are using storyboards, why not just set the title on the tab controllers in the storyboards? 如果使用情节提要,为什么不只在情节提要中的选项卡控制器上设置标题?


or 要么

You can also set this in your appDelegate.m file for each view controller that is in your tab controller by doing this: 您还可以通过执行以下操作在appDelegate.m文件中为选项卡控制器中的每个视图控制器进行设置:

[[self.tabBarController.viewControllers objectAtIndex:<index of the controller you want to change>] setTitle:@"The Title"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM