Ethan G
Ethan G

Reputation: 1477

How to remove "More" tab in UITabBarController that has custom tab UI (not using tab bar)

I'm using a UITabBarController as a backing to present multiple view controllers, but I'm not using the default tab bar at the bottom for the user to tap on the tabs. Instead, I'm presenting a slide-out menu from the left that displays a list of tabs in a table view. So the user can tap on one of the cells in the table view and switch to that tab. This is a very common paradigm for displaying multiple view controller tabs without using the tab bar at the bottom of the UITabBarController.

Now that I've added more tabs, I'm having an issue with one of my tabs opening to UITabBarController's "More" controller. I don't need or want this "More" controller because I'm displaying my tabs in a scrollable list, not in a tab bar that has finite space.

How can I remove the "More" tab or tell my UITabBarController not to present the "More" screen? Is there some option to disable this?

Upvotes: 4

Views: 1868

Answers (1)

Hoogle
Hoogle

Reputation: 413

A workaround: Find the right timing for hiding more navigation bar. Add those code to your subclass of UITabBarController:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if (self.viewControllers.count > 5)
    {
        self.moreNavigationController.delegate = self;
    }
}

in navigation delegate callback:

- (void)navigationController:(UINavigationController *)navigationController
  willShowViewController:(UIViewController *)viewController
                animated:(BOOL)animated

{
   navigationController.navigationBarHidden = YES;
}

Upvotes: 1

Related Questions