0
votes

I have an app, where there's a UITabBar with 5 tabs. When user shakes the device, I want the UINavigationBar to push an UIImageView. When I show the UIImageView, I need to hide both tab and nav bars. After that, when user taps the UIImageView, the NavBar appears again and user can go to the UIImageView's parent view. I make the Nav Bar appear like this:

[[self navigationController] setNavigationBarHidden:NO animated:YES];

But in two tabs I have to make the Nav Bar appear, so user can switch to UIImageView's parentView and then, when the parent view appears, hide the nav bar. How can I do it?

2

2 Answers

0
votes

I think you should set up a UITabBarController delegate and implement this method:

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    // Put real logic here
    BOOL shouldHideNavBar = (viewController == myViewController1 || viewController == myViewController4);
    [[self navigationController] setNavigationBarHidden:shouldHideNavBar animated:YES];
}
0
votes

That was easier than I thought. I just have to put

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