Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Height of UINavigationBar changes after modal flip animation

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:

http://i.imgur.com/qFlK2oB.jpg

What am I missing?

like image 637
Koonga Avatar asked Oct 02 '13 06:10

Koonga


People also ask

Which method is used to display the view controller in the Uinavigationcontroller container in Swift?

Tapping the back button in the navigation bar at the top of the interface removes the top view controller, thereby revealing the view controller underneath. Use a navigation interface to mimic the organization of hierarchical data managed by your app.

What is the height of navigation bar in iOS?

Hi, in ios, the default height of navigation bar is 44 pts.

How do I change the navigation bar on my Iphone?

A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.

What is a navigation bar in iOS?

According to Apple documentation, "An iOS Navigation bar appears at the top of an app screen, below the status bar, and enables navigation through a series of hierarchical app screens.


1 Answers

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

like image 196
devguydavid Avatar answered Nov 02 '22 22:11

devguydavid