0
votes

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.

storyboard

View2 code

View3 code

1
Nope, not clear...need to see code. - borrrden
there's very little code to see, since the presentation of the controllers is made in the storyboard. The only code I have is the "[self dismissModalViewController animated:YES]" - Aleph72
What is the difference between your controllers? The look exactly the same! Why do you need three identical controllers? - shannoga

1 Answers

0
votes

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.

  • What is your hierarchy?
  • Where do you call dismiss to your 3 view.

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