UINavigationBar jumps 20px during transition fromFromViewController

While trying to use Apple's containment UIViewController, I got a problem animating the transition between two UIViewControllers.

Here is the setup ... I created a UITabBarController and in one of the tabs I created a UIViewController as a container. This ViewController manages the transition between UIViewController and UINavigationController. Representation:

Display of VC 1

When you click Next, the view begins a transition with a flipFromRight transition. During navigation, the navigation bar is in "view" but is positioned 20 pixels down from the top edge of the view. Picture below:

enter image description here

Green is the background color of the container. When the new view completes the transition, the navigation bar will close to the top of the view, and the end result is:

Final state

The time to snap in place is independent of the animation duration. I reach the final state I want, but the transition is a problem.

I measured the lifecycle of the viewController and the navbar and UITableView frames are specified in the XIB. Xib looks like this:

xib Configuration of View

Here is the code:

In -viewDidLoad -

_fromVC = [[FromVC alloc] initWithNibName:@"FromVC" bundle:nil delegate:self];

[self addChildViewController:_fromVC];
[self.view addSubview:_fromVC.view];
[_fromVC didMoveToParentViewController:self];

      

In the button handler -

- (void)buttonSelected

      

{

//
//  Create the "to" View controller
//
ToVC *toVC = [[ToVC alloc] initWithNibName:@"ToVC" bundle:nil];

//
//  Create the navigation controller for the study activity
//
_toNavCon = [[UINavigationController alloc] initWithRootViewController:toVC];

[self addChildViewController:_toNavCon];
[_fromVC willMoveToParentViewController:nil];

[self transitionFromViewController:_fromVC
                  toViewController:_toNavCon
                          duration:0.7
                           options:UIViewAnimationOptionTransitionFlipFromRight
                        animations:nil
                        completion:^(BOOL finished) {
                            [_fromVC removeFromParentViewController];
                            [_toNavCon didMoveToParentViewController:self];
                        }];

      

}

The for controller is missing code that changes the appearance of the view controller.

One more bit of information ... When I "toggle the status bar while talking" in the simulator, the space at the top of the navigation bar is the height of the Inbox status bar.

I have looked all over the internet and nothing seems to help. Has anyone seen this and has anyone fixed it?

+3


source to share


1 answer


I found the answer! UINavigationController subclass and override

- (BOOL)wantsFullScreenLayout{

  return NO;

}

      



Apparently UINavigationController and UITabController always want full screen (default YES) - setting for status bar - and you cannot set this property in any other way. It works for me.

+5


source







All Articles