Reputation: 35090
How can I change view controller in UITabBarController
. UITabBarController
is created from Storyboard
. I.e. want to remove last item. Enable to NO UITabBarItem
will only disable button, but not hide it.
Upvotes: 1
Views: 351
Reputation: 131
First you need to get viewcontrollers for an array and change the array. After modification assign back to UITabBarController
NSMutableArray *viewCotrollers = [[NSMutableArray alloc]initWithArray:[tbc viewControllers]];
[viewCotrollers removeLastObject];
[tbc setViewControllers:viewCotrollers animated:YES];
To get the TabBarController you can use following code
UITabBarController *tbc = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"tabBarController"];
Todo this you need to set identifier for your UITabBarController on storyboard
Upvotes: 3