0

I am making an app with navigation controllers through storyboarding in Xcode 4.2.

I want to hide all navigation bars when each view is loaded and with a click of a button which is on top of the screen, the navigation bar should show for a few seconds (I have used NStimer for that) and then hide again.

So far I have managed to do that but the problem is that when I push another view and then return to the previous view, the button can be clicked but the navigation bar is not appearing again.

Here is my code:

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

-(IBAction)top {
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    hideNavTimer = [NSTimer scheduledTimerWithTimeInterval:3
    target:self selector:@selector (HideNav)     userInfo:nil repeats:NO];
}

-(void)HideNav {
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    [hideNavTimer invalidate];
    hideNavTimer=nil;
}

I use this code in each view i push.

What am I doing wrong?

Pantelis Proios
  • 1,359
  • 1
  • 20
  • 32

1 Answers1

2

You should put it in viewWillAppear:

-(void)viewWillAppear:(BOOL)animated:
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}
jbat100
  • 16,757
  • 4
  • 45
  • 70
  • I did but it still doesn't make the Navigation Bar visible when you return to the previous view. – Pantelis Proios Nov 24 '11 at 16:49
  • I made a test. In the code you provided i switched setNavigationBarHidden:NO. When i returned to this view the Nav bar should be visible however it wasn't. I guess that something keeps the "setNavigationBarHidden:YES" when you return from one view to the previous..... – Pantelis Proios Nov 24 '11 at 18:13