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

2 thoughts on “Programmatically Removing a Tab from UITabBarController

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s