Setting UITabBarController item names at application startup

I have a UITabBarController with 5 tabs, how can I set tab headers when the application starts? The reason for this is because I want to display the names of the tablets based on the system language (for example, in English or Spanish)

Hello

+4
source share
1 answer

Setting up the tablet headers is pretty simple:

This configures the tabbarcontroller programmatically in your application delegation application applicationDidFinishLaunching. It is assumed that all viewcontrollers are placed in the viewControllers array. You can skip this section if you configured your tabbarcontroller via ib.

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

You can set headers:

 [[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, take a look here . Put all your localized strings in plist files and start with iOS localization methods. After starting it is very convenient.

+15
source

All Articles