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.