4

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.

4
  • 1
    What 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. Commented Nov 12, 2011 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. Commented Nov 13, 2011 at 3: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. :/ Commented Jan 28, 2012 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. stackoverflow.com/questions/8190980/… Commented Jan 28, 2012 at 19:03

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.