0
votes

Here is my setup: App launches with a main screen that has 4 buttons. each button takes you to a new view/childview. Each child view has a back button( via navigation controller) to take you back to the main/menu screen. Easy enough. And works great. however, here is what i want to do: Main screen has 4 buttons to 4 different views. On the main screen all you see is the main page/menu, NO TABBAR. However, when you go to any of the 4 view options a tab bar will be present that is populated with tabs to the 4 child views. AND there will also be a navigation bar if we wanted to go back to the Main menu.

So essentially: Main Menu shows NO TAB BAR. 4 child views show Tab Bar AND navigation bar. I messed around with a bunch of stuff but can't get it to work. Any thoughts about how to do this?

2

2 Answers

0
votes

You can achieve this by having your storyboard look like this:

Storyboard Image

Then in YourMainMenuViewController's implementation:

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

    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

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

    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    UITabBarController *tabVC = segue.destinationViewController;

    if ([segue.identifier isEqualToString:@"Tab1"]) {
        tabVC.selectedIndex = 0;
    }
    else if ([segue.identifier isEqualToString:@"Tab2"]) {
        tabVC.selectedIndex = 1;
    }
    else if ([segue.identifier isEqualToString:@"Tab3"]) {
        tabVC.selectedIndex = 2;
    }
    else if ([segue.identifier isEqualToString:@"Tab4"]) {
        tabVC.selectedIndex = 3;
    }
}

Although I advise against putting a tab bar controller inside a navigation controller like this as it's kind of confusing UI.

0
votes

To show navigationBar on viewWillAppear implement this

[self.navigationController setNavigationBarHidden:NO];

To show tabBar on viewWillAppear implement this

self.tabBarController.tabBar.hidden = NO;

You can set them YES to make them hidden in your menu on viewWillAppear

Hope it helps