2

I want to embed a UITabBarController inside a UINavigationController. I found a similar question here on StackOverflow, but my attempted implementation does not let me add a UIBarButtonItem to navigationItem.rightBarButtonItems.

Below is a screenshot of my implementation. "Button 1" and "Button 2" are not displayed in the running app. Any ideas what I'm doing wrong?

UITabBarController inside UINavigationController screenshot

Community
  • 1
  • 1
royco
  • 5,409
  • 13
  • 60
  • 84

1 Answers1

3

I think your "Button 1" and "Button 2" are not visible because there are overlapped by the navigation bar of the root navigation controller.
So you can do the following:
Step 1. Create a UITabBarController subclass and assign it in IB to your tab bar controller.
Step 2. In -viewWillAppear: method just hide navigation bar of root navigation controller

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

Step 3: Bring back navigation bar when you go back to root view

- (void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}    
arturdev
  • 10,884
  • 2
  • 39
  • 67