1

I have two UIViewControllers, A and B.

A is hiding the UINavigationBar and B is not. When animating (with the default animation) from A to B, the navigation bar has to become visible. The navigation bar just pops in at some point (viewWillAppear or viewDidAppear) instead of sliding in with the UIViewController B.

When going back from B to A, the navigation bar is smoothly sliding back out.

How can I achieve the desired effect when animating from A to B?

Max
  • 2,699
  • 2
  • 27
  • 50

2 Answers2

1

In ViewController B, one has to simply do:

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

I wasn't aware that this also controls the animation while doing a full view controller transition. I thought it only controls animation the navigation bar out to the top and back in.

Max
  • 2,699
  • 2
  • 27
  • 50
0

You can try the following:

Use a instance variable to do this:

self.navigationController setNavigationBarHidden:hide animated:animated];
_shouldHideStatusBar = hide;

And implement the following function:

- (BOOL)prefersStatusBarHidden{
    return _shouldHideStatusBar;
}

The setNavigationBarHidden:animated function will automatically call prefersStatusBarHidden function. If it doesn't you can call it with the following UIViewController's method:

[self setNeedsStatusBarAppearanceUpdate];

And of course you can choose your status bar hiding animation style with:

- (UIStatusBarAnimation) preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationSlide;
}

Let me know if this helps. Good luck!!

(I got this answer here: How to slide in/out statusBar and navigationBar simultaneously?)

Community
  • 1
  • 1
Horray
  • 693
  • 10
  • 25
  • Hide UINavigationBar in your AppDelegate method when you declare it, and Unhide it on UIViewController B. I think your problem will be resolved. – iPhone May 04 '15 at 12:55
  • @Horray, I think you're missing the point. I don't care about the statusBar, I'm only talking about the navigation bar. Maybe I'm getting it wrong, but I don't know how this would solve my problem. – Max May 04 '15 at 17:29