Custom animation for UINavigationController push does not display navigation correctly

In custom segue, I have the following simple transition:

- (void) perform {
    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;
    [UIView transitionWithView:src.navigationController.view duration:1
                       options:UIViewAnimationOptionTransitionFlipFromBottom
                    animations:^{
                        [src.navigationController pushViewController:dst animated:NO];
                    }
                    completion:NULL];
}

View content animated perfectly. However, when performing an animation, the navigation bar at the top has a damaged layout (all buttons are messed up in the upper left corner, without a name), appear in place only after the animation is completed. Does anyone know what I did wrong and how to fix it? Thank!

+5
source share
2 answers

Figured out my problem. The source code is really incorrect, since the UINavigationController works and interacts with managed UIViewControllers. (Annoyingly, like what I was doing in the OP can be found as a solution in older SO posts.)

, ( ):

- (void) perform {
    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;
    [UIView transitionFromView:src.view
                        toView:dst.view
                      duration:1
                       options:UIViewAnimationOptionTransitionFlipFromBottom
                    completion:nil];
    [UIView transitionFromView:src.navigationItem.titleView
                        toView:dst.navigationItem.titleView
                      duration:1
                       options:UIViewAnimationOptionTransitionFlipFromBottom
                    completion:nil];
    [src.navigationController pushViewController:dst animated:NO];
}

Quibble: , , . :

    [UIView transitionFromView:src.navigationController.view
                        toView:dst.navigationController.view

, 1) destination navigationController , nav, 2) , ! ,

- , , , ... , ... , ( UINavigationItem), . , . (docs)

+5

""?

[src.navigationController pushViewController:dst animated:YES];

 [UIView transitionFromView ...  

viewDidLoad .

0

All Articles