This problem is a little hard to explain. I’ll do my best, hoping to make myself clear.
I’ve got 3 view controllers, let’s call them ‘View1’, ‘View2’ and ‘View3’.
On the top of their views, there are 3 buttons with the same names.
Each button presents modally its respective view.
I’ve done this simply by ctrl-dragging, in the storyboard, the View2 button to the View2 controller and the View3 button to the View3 controller.
View 1 is the starting controller, so its button is not connected to anything.
Now from View1 I can go to View2 and View3 by tapping those buttons.
In View2 and View3, when I tap the View1 button, I dismiss the modal view controller, going back to View1.
To go from View2 to View3, I’ve also connected the View3 button to the View3 controller.
Now what happens is:
if I go to View 3 from View1 and then tap on View1 button, I get back to View1 and that’s correct.
But if I tap on View2 from View3, I still get back to View1, and that’s not correct.
I’m stuck on this thing and can’t find a solution. I hope I made myself clear and that someone could help.
Thanks.
Edit: adding some images.
From left to right you can see the View1, View2 and View3 controllers.
The View1 is not a root controller, it comes from another controller.
The two pieces of code you see are respectively from the View2 and View3 controllers.



It is hard to help you without understanding your view hierarchy. I can guess that your 1 view controller is your root view controller and that that’s why you get back to it.
And finally –
It seems that a UISCrollView will be better for your scenario.
Simply create a UISCrollView and add the views of your view controllers to it. then place a toolbar with button for each of the controllers and slide the scrollview programmatically to each view when a button is tapped.
If you need more hemp with that I will be happy to help.
Shani