I’m starting a navigation flow. I’m starting from AViewController and I’m navigating in app. AViewController -> BViewController -> CViewController -> DViewController. While in DViewController, I want to push EViewController. But I want AViewController to do this push, not DViewController. So I want my presentingViewController to be AViewController. With this, other ViewControllers(BViewController, CViewController, DViewController) have to be dismissed. In the last case, my navigation flow should be like this: AViewController -> EViewController. Is there a way to do this ?
4
Answers
do you want eviewcontroller back to Aviewcontroller, or you can push Aviewcontroller to Eviewcontroller
Then
You need to pop all the view controller till
AViewcontroller
asThen
Now it is AViewcontroller -> EViewcontroller
Another solution
OR
Add this in EViewcontroller’s
viewDidAppear
First , create a function that helps you to push
A to F
inViewcontroller
AAnd where you go back to
root and push F
call this :To replace the navigation stack of a view controller, use
setViewControllers(_, animated:)
. If you pass in your existingAViewController
and a newEViewController
then your final navigation stack will be just those two.There is no need to manually rebuild the stack you want by pushing and popping individual controllers.