8

I've noticed that when I segue to a Naviagtion Controller, the navigation bar jumps slightly right after the flip animation completes.

It only does this when I use a flip horizontal segue, and not when I use the default slide up animation.

Here is a GIF I've made to illustrate the problem (sorry about the tiny size!):

http://i.imgflip.com/3ym0y.gif

Take note of the Nav bar with the title "Modal" -- notice it jumps down ~20 pixels after the animation.

The example above was created with a fresh project -- I have not subclased UINavigationController or UINavigationBar. Here is the storyboard, in case it helps:

https://i.stack.imgur.com/Sven4.jpg

What am I missing?

Koonga
  • 230
  • 3
  • 9

1 Answers1

20

Add this to viewWillAppear in the controller you're presenting modally:

- (void)viewWillAppear:(BOOL)animated
{
    // Workaround #1 for jumpy navbar
    [self.navigationController.navigationBar.layer removeAllAnimations];
}

And when dismissing the controller (so in the same controller as above):

// Workaround #2 for jumpy navbar
[UIView transitionWithView:self.navigationController.view
                  duration:0.75
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:nil
                completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];

See https://stackoverflow.com/a/19265558/254603

Community
  • 1
  • 1
devguydavid
  • 3,917
  • 1
  • 19
  • 18
  • Can anyone verify that the default flip animation duration is actually 0.75? Seems like it also be 1.0 or a number of values in that range. Thanks! – James May 13 '14 at 15:43