Steven Fisher
Steven Fisher

Reputation: 44866

Navigation bar jumps out from under status bar?

I have a button in my main view controller that pushes a navigation controller with an embedded view controller using a segue.

When the new view controller is presented, the navigation bar on it briefly appears under the status bar. (The status bar is not hidden.) The contents (which are relative to the top layout guide) are in the correct location. As soon as the animation is complete, it fixes itself.

When the view is dismissed again, the same thing happens: the main view controller briefly overwrites the status bar. For the main view controller, this is a little more significant as it's based on a UITableViewController; the entire table jumps. Again, when the animation is complete the view controller fixes itself.

I've tried turning off translucency on the navigation bar, but it only makes the problem more obvious. All of this works as expected on iOS 6.

I've uploaded a minimalist test case here: https://github.com/tewha/FlipTest

Upvotes: 4

Views: 2428

Answers (4)

user1951992
user1951992

Reputation:

This is a bug in UK kit. Avoid using the standard methods

'performSegueWithIdentifier' or 'presentViewController'

Here I transition from one controller to another, then transition back in the delegate callback, using UIView transition animations.

-(void)photoButtonPressed:(NSNotification*)notification
{        
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Media"
                                                         bundle:nil];

    UINavigationController *navCon = [storyboard instantiateInitialViewController];

    PhotoCaptureViewController *controller = navCon.viewControllers.firstObject;
    controller.delegate = self;

    CustomTabBarViewController *tabBarController = (CustomTabBarViewController*)self.tabBarController;

    [UIView transitionWithView:self.navigationController.view duration:0.75 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                        [tabBarController.parentViewController addChildViewController:navCon];
                        [tabBarController.parentViewController.view addSubview:navCon.view];
                    } completion:^(BOOL finished) {
                        [navCon didMoveToParentViewController:tabBarController.parentViewController];
                    }];
}

-(void)photoCaptureViewController:(PhotoCaptureViewController *)controller dismissButtonPressed:(UIButton *)dismissButton
{
    CustomTabBarViewController *tabBarController = (CustomTabBarViewController*)self.tabBarController;

    [UIView transitionFromView:controller.navigationController.view toView:tabBarController.view duration:1 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
        [controller.navigationController willMoveToParentViewController:nil];
        [controller.navigationController removeFromParentViewController];
        [controller.navigationController.view removeFromSuperview];
    }];

}

This is a great read about container views Khanlou's blog post

Upvotes: 0

Tosin Afolabi
Tosin Afolabi

Reputation: 151

There is a Problem in the ios 7 with navigation bar ,Navigation bar appear over the views or showing gap between the nav bar and view , You can solved this problem with the help of following code

There has been a new property introduced in iOS 7 that lets you adjust the layout behavior as in previous versions of iOS. this code in your view controller, and you should be good The space your navigation bar takes up should be accounted for automatically

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
    self.edgesForExtendedLayout = UIRectEdgeNone;

Answer obtained from iOS 7 navigation bar jumping / stretching upon viewDidAppear

Upvotes: 0

dcorbatta
dcorbatta

Reputation: 1889

Another simple trick is do this:

In the MasterViewController

When is preparing for Segue:

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    [UIView transitionWithView:self.navigationController.view
                      duration:0.75
                       options:UIViewAnimationOptionTransitionFlipFromRight
                    animations:nil
                    completion:nil];
}

And when Unwind the AboutViewController

- (IBAction)aboutUnwind:(UIStoryboardSegue *)segue {

[UIView transitionWithView:((UIViewController *)segue.sourceViewController).view
                  duration:0.75
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:nil
                completion:nil];

}

Upvotes: 3

Léo Natan
Léo Natan

Reputation: 57040

This is a bug in the layout system of iOS7. I found that reducing the height of the navigation controller's view (not the pushed view controller's!) by the status bar height and placing it in y = status bar height will help a lot, but there will still be a small flicker where the status bar "merges" with the navigation controller.

As a side not, see if the bug still exists in iOS7.1b1.

Upvotes: 1

Related Questions