UITabViewController hide / make appear a view in code

278 Views Asked by At

I am using Xcode 5.1.1. I have a UITabViewController and used Storyboard to add 10 views to it. It works great and I get the "more" and table view all for free.

I only want to show some of the tabs at the beginning. Once the user logs in with their Google+ account (I actually got that working), then I want the rest of the tabs to appear, since they are content sensitive to the user logging in.

I have found: [[[[self.tabBarController tabBar]items]objectAtIndex:3]setEnabled:FALSE];

But I do not want the items just greyed out, I want them removed completely until they log in. Thanks

1

There are 1 best solutions below

0
On

Get all the tabbarviewcontrollers and remove them specifying the index of your need as follows:

NSMutableArray *tabbarViewControllers = [NSMutableArray arrayWithArray:[self.tabBarController viewControllers]];
[tabbarViewControllers removeObjectAtIndex: 0 or 1 or 2];
[self.tabBarController setViewControllers: tabbarViewControllers ];