xcode4 - 启动应用程序时设置 UITabBarController Items 标题

标签 xcode4 uitabbarcontroller tabitem

我有带有 5 个选项卡的 UITabBarController,如何在启动应用程序时设置选项卡标题?这背后的原因是因为我想根据系统语言(例如英语或西类牙语)显示标签标题

问候

最佳答案

设置标签栏的标题非常简单:

这会在您的应用委托(delegate)的 applicationDidFinishLaunching 方法中以编程方式设置一个 tabbarcontroller。假设您已将所有 View Controller 放入 viewControllers 数组中。如果您已通过 ib 设置了 tabbarcontroller,则可以跳过该部分。

UITabBarController *tabBarController = [[[UITabBarController alloc] init] retain];
tabBarController.delegate = self;
[tabBarController setViewControllers:viewControllers animated:NO];
tabBarController.selectedIndex = 0;

您可以通过以下方式设置标题:
[[tabBarController.tabBar.items objectAtIndex:0] setTitle:@"title A"];
[[tabBarController.tabBar.items objectAtIndex:1] setTitle:@"title B"];
[[tabBarController.tabBar.items objectAtIndex:2] setTitle:@"title C"];

多语言项目,请看here .将所有本地化字符串放入 plist 文件并从 iOS 的本地化方法开始。一旦开始,它非常方便。

关于xcode4 - 启动应用程序时设置 UITabBarController Items 标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6744716/

相关文章:

ios - 通过 segue 返回后 SWRevealViewController 是否为零?

ios - UITabbar 图像上下移动

c# - WPF/C# : How does one reference TabItems inside a TabControl?

swiftui - 我无法在 SwiftUI 中将 NavigationItemTitle 覆盖到 TabView 中

ios - Xcode 4 : Exceptions not being logged to the console

ios - 在 Swift 4 上调整 UIImage View 的大小

c++ - Xcode 4 C++ 头文件与另一个头文件的相对路径

带有登录叠加层的 iOS 5 Storyboard(iOS 5.1;Xcode 4.3.3)?

swift - 直接从 UITabBarController 和通过 UINavigationController 选择 UIViewController

wpf - 如何使用嵌套文本更改 WPF TabItem 的文本前景?