I am currently working on the following situation, i need to push two viewController (A and B) in sequence in short time.
So this is what i do.
- First call,
[UINavigationController pushViewController:vcA animated:yes] - In
[navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated], i call[UINavigationController pushViewController:vcB animated:yes]
Since i have overrides some of functions in [UINavigationController pushViewController:animated], i want [UINavigationController pushViewController:animated] only triggered twice, one when pushing vcA and one when pushing vcB.
However, the current situation is that [UINavigationController pushViewController:animated] will be triggered for three times:
- First time when we call
[UINavigationController pushViewController:vcA animated:yes] - Second time when we call
[UINavigationController pushViewController:vcB animated:yes]. However, this is strange because at this point, this is not doing anything. I checkedNavigationController.viewControllersand find thatvcBdid not get pushed - Third time,
[UINavigationController pushViewController:vcB animated:yes]is triggered again, and it is triggered by[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:], the full stacktrace can be seen here
So my question is, where did the third [UINavigationController pushViewController:vcB animated:yes] come from? I am certain that i did not override any _UIViewControllerTransitionCoordinator.
If you really want to do this (not a best practice)
Try this code: