Search code examples
ioshiddennavigationbar

hiding the aView's Navigationbar push bView is OK.but pop Can see the black bars


SDK 6.1, Target 6.1, use storyboard

aView has a a UIButton. I use action segue [push] to the bView

When I click this button push bView is ok

But I pop aView have a back bars, how do I solve this problem?

aView.m

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

bView.m

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setHidden:NO];
}

Solution

  • I got what is your problem. You are hiding your navigation bar in the viewWillAppear: method of viewA and you are doing it without animation.

    Try this

    // This will add an animation like slide out. So you may won't like it.
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    

    If it is not working, then add this code in bView.m

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