Programmatically Removing a Tab from UITabBarController

Programmatically Removing a Tab from UITabBarController

There is a right way, and a wrong way, to remove a tab from a tab bar in a tab bar controller within an iOS app. I’m not going to show the wrong way.

Without fanfare:

        // Remove the third tab from a tab bar controlled by a tab bar controller
	NSMutableArray * vcs = [NSMutableArray 
                                arrayWithArray:[self.tabBarController viewControllers]];
	[vcs removeObjectAtIndex:2];
	[self.tabBarController setViewControllers:vcs];
Advertisements