I mentioned this question and a few questions about the transition of the view / view controller, but so far I have not been able to find a satisfied answer. Most solutions suggest flipping views instead of view controllers. However, the two view controllers in my application have a completely different logic of work and implementation, so I avoid mixing them.
In my application, I have a modal view controller FrontViewController that is built into the NavigationController. After clicking one button to view, the modal view controller should turn to the BackViewController and vice versa. I have ever tried the following in FrontViewController :
let navi = UINavigationController(rootViewController: backController) navi.modalPresentationStyle = .CurrentContext navi.modalTransitionStyle = .FlipHorizontal self.presentViewController(backController, animated: true, completion: nil)
This works almost the same as me, except that it also translates the navigation bar. Moreover, if I reject the modal view, only the view manager at the top of the stack is fired, while I was not able to get the correct parent / presentation controller to reject all other stack controllers in the modal view.
Thus, I also tried to prevent the viewcontroller stack and use the transitionFromViewController in the FrontViewController , using the same navigation controller instead:
self.navigationController!.addChildViewController(backController) self.willMoveToParentViewController(nil) self.navigationController!.transitionFromViewController(self, toViewController: backViewController, duration: 1, options: .TransitionFlipFromLeft, animations: {}, completion: ({Bool -> Void in self.removeFromParentController() c.didMoveToParentViewController(self) }))
Then I got this runtime error on execution: Parent view controller is using legacy containment in call to -[UIViewController transitionFromViewController:toViewController: duration:options:animations:completion:]
So, how does the transition between two view controllers while preventing them remain on the view manager stack?