i currently have a number of viewControllers that have a relationship with my tabBarController through Storyboard. Given certain setting, i would like to programatically make a certain viewController hidden or visible. I can hide the whole tabBar, but thats not what i'm after. I have been playing in Xcode and scouring interwebs, but can't find a solution. something along the lines of below that doesn't work me!
[[self.tabBarController.tabBar.items objectAtIndex:2] setHidden:YES];
Used similar code to fix the problem.
NSMutableArray *newTabs = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[newTabs removeObjectAtIndex: 3];
[newTabs removeObjectAtIndex: 2];
[self.tabBarController setViewControllers:newTabs];
It turns out you can do it in one line:
tabBarController?.viewControllers?.remove(at: 1)
Assume that 1
is the index of the item you want to remove.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With