Have read some great tutorials online about the new storyboarding feature of xcode 4.2. I just cant seem to find information on conditional storyboarding. For example making a storyboard where one button can take you to different screens based upon the value of a boolean variable.
Asked
Active
Viewed 3,160 times
4
-
1What exactly are you trying to achieve? There are almost always multiple solutions to a particular problem. To me, it sounds like you should be using tags and switches. – Jezen Thomas Nov 12 '11 at 22:25
-
Hmm not sure how to rephrase my question. Currently in the new xcode storyboard feature i have the ability to add a round rect button on a viewcontroller(screen). I can now link this button to a second view controller so when its clicked it takes me there. This happens behind the scenes and no code is generated for me to add /modify any of this behavior..atleast from what i can see. What i want to do is use the storyboard so instead of taking me to the second view controller it will take me to the third based on the condition of a variable. – kunal Nov 13 '11 at 03:14
-
I've been looking around a bit and haven't found a good solution here -- it seems you have to have an existing segue in the storyboard and then use it. (Or have access to your next viewController as a property to create a programmatic segue, kind of defeating the point of segues) That means (for me) that I will create an unused item that has a segue, give it a tag, and then call that segue with my tag via an action on the button. Seems like there should be a better way. :/ – slycrel Jan 28 '12 at 18:28
-
Apparently I would post this just before finding an acceptable answer... you can apparently connect each view controller with a segue then call it programatically. found this method which seems to do the trick; connect your view controllers with the segue then call it programmatically. http://stackoverflow.com/questions/8190980/ios-make-seque-wait-for-login-success – slycrel Jan 28 '12 at 19:03
1 Answers
5
This scenario is addressed in episode 7 of the Stanford 2011 lectures on iOS development, on Universal Applications. Setup a target action for the button and in the code use performSegueWithIdentifier to a different segue.
This also allows you the flexibility to have an iPad version which doesn't do a segue because the desired view is already onscreen in a split view.
Andy Dent
- 17,578
- 6
- 88
- 115