How to set tab bar item title programmatically in objective c? How to set tab bar item title programmatically in objective c? xcode xcode

How to set tab bar item title programmatically in objective c?


You can set all the UITabBar icons in an easy way. You can do this in your viewWillAppear: method:

[[self.tabBarController.tabBar.items objectAtIndex:0] setTitle:NSLocalizedString(@"BotonMapas", @"comment")];[[self.tabBarController.tabBar.items objectAtIndex:1] setTitle:NSLocalizedString(@"BotonRA", @"comment")];[[self.tabBarController.tabBar.items objectAtIndex:2] setTitle:NSLocalizedString(@"BotonEstado", @"comment")];[[self.tabBarController.tabBar.items objectAtIndex:3] setTitle:NSLocalizedString(@"LabelInfo", @"comment")];

Swift 3.1 Solution

self.tabBarController?.tabBar.items?[0].title = NSLocalizedString("BotonMapas", comment: "comment")self.tabBarController?.tabBar.items?[1].title = NSLocalizedString("BotonRA", comment: "comment")self.tabBarController?.tabBar.items?[2].title = NSLocalizedString("BotonEstado", comment: "comment")self.tabBarController?.tabBar.items?[3].title = NSLocalizedString("LabelInfo", comment: "comment")


How I do it in the actual View Controller (not the App Delegate):

// set tab titleself.title = @"Tab Title";// optionally, set different title for navigation controllerself.navigationItem.title = @"Nav Title";// Note: self.title will reset Nav Title. Use it first if you want different titles


An easy way to do this : In your viewController2 's viewDidLoad method, set self.title = @"MyTitle";