I am very new to iP开发者_如何学Pythonhone and Xcode. I am trying to create a tab-based application, in that from the first page, when a button is clicked, I need to remove/hide some of the tabs added in the tab bar.
Can any one help me out please.
Thanks and Regards, Bala.
Let's say you want to remove the fourth tab from the tab bar (tab index == 3). Just modify the tabbar controller's viewControllers
array accordingly:
NSUInteger indexToRemove = 3;
NSMutableArray *controllersToKeep = [NSMutableArray arrayWithArray:tabBarController.viewControllers];
UIViewController *removedViewController = [[controllersToKeep objectAtIndex:indexToRemove] retain];
[controllersToKeep removeObjectAtIndex:indexToRemove];
[tabBarController setViewControllers:controllersToKeep animated:YES];
Note that if you want to keep the removed/hidden view controller around in the background, it's essential that you retain it before removing it from the tab bar (see line 3).
精彩评论