0

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

Aleph72
  • 877
  • 1
  • 13
  • 40
  • Nope, not clear...need to see code. – borrrden Jul 14 '12 at 15:55
  • 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 Jul 14 '12 at 15:58
  • 1
    What is the difference between your controllers? The look exactly the same! Why do you need three identical controllers? – shannoga Jul 14 '12 at 16:23

1 Answers1

0

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

shannoga
  • 19,649
  • 20
  • 104
  • 169
  • I've added some images. I'd rather not use scrollviews because each scene is made by many views, buttons and other UI elements. – Aleph72 Jul 14 '12 at 16:11
  • And why do you think it is a problem? – shannoga Jul 14 '12 at 16:19
  • First it is very simple. And we can help you with it. Second, from looking at yor story board I am not sure you need more then 1 view controller. Can you explain the changes in your views? – shannoga Jul 14 '12 at 16:25
  • They are used to input body temp, glycemia and pressure values. The only thing that changes is the pickerview and how the data is shown in the tableview. They call different methods to insert the data in a DB. How could I use only one controller to do that? – Aleph72 Jul 14 '12 at 17:38
  • Well, at the end I did it. I've been able to use just one view controller and change the picker view when one of the buttons is pressed. Thank you for pointing me to the right direction. – Aleph72 Jul 14 '12 at 18:50