Atul Bhatia
Atul Bhatia

Reputation: 1795

ios navigation controller push view controller but have back button point somewhere else

The scenario I have is this. I have 5 view controllers: Root, A, B, C, D

I am currently on screen B and my navigation stack contains Root, A, B.

Once the user performs a certain action on B I want to navigate to D without any other screens showing, and I want the back button to point to C. The full navigation stack should look like: Root => C => D.

So effectively, I want to pop to my root view controller, then push C, and push D. However, I don't want Root and C to appear.

Is this possible?

Upvotes: 0

Views: 873

Answers (1)

Wain
Wain

Reputation: 119031

Use the setViewControllers:animated: method in B to push an instance of C and D at the same time. It will look like a simple push to the user but in reality you are effectively popping and pushing multiple views.

Upvotes: 2

Related Questions