I have 2 UIViewControllers
, UIViewControllerA
and UIViewControllerB
in a UINavigationController
stacked in this manner -> [UIViewControllerA, UIViewControllerB]
.
Now instead of popping UIViewControllerB
to reach UIViewControllerA
, I want to swap the 2 objects in navigation stack.
So I do this :
self.navigationController?.setViewControllers([UIViewControllerB, UIViewControllerA], animated: true)
After this when I query my navigation stack, there is only 1 view controller i.e. [UIViewControllerA]
Question 1: Why I cannot find UIViewControllerB as root view controller?
Question 2: I want to again swap the 2 view controllers to reach UIViewControllerB. How to achieve this, if possible?