开发者

Set UITabBarController Items titles while launching the application

开发者 https://www.devze.com 2023-03-21 01:44 出处:网络
I have UITabBarController with 5 tabs, how can I set tabs titles while launching the application? The reason behind this is becau开发者_运维知识库se I want to display tabs titles based on system langu

I have UITabBarController with 5 tabs, how can I set tabs titles while launching the application? The reason behind this is becau开发者_运维知识库se I want to display tabs titles based on system language (English or Spanish for example)

Regards


Setting the tabbar's titles is pretty easy:

This sets up a tabbarcontroller programmatically in your app delegate's applicationDidFinishLaunching method. It is assumed you have all viewcontrollers put in the viewControllers array. You may skip that section, if you have set up your tabbarcontroller via ib.

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

You may set the titles by:

[[tabBarController.tabBar.items objectAtIndex:0] setTitle:@"title A"];
[[tabBarController.tabBar.items objectAtIndex:1] setTitle:@"title B"];
[[tabBarController.tabBar.items objectAtIndex:2] setTitle:@"title C"];

When it comes to multilingual projects, have a look here. Put all your localized strings into plist files and start with iOS' localization methods. Once started, it is very handy.

0

精彩评论

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