Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Kantor
2,183 PointsHow to switch views programmatically in Swift?
I'm also a bit confused on what a "Segue" is and I've seen it in a few answers related to this question, but simply put, how do I switch views based on say, a Users Session..
if(loggedOut = true) { show sign in view }else {do nothing}
3 Answers
piquussnsx
2,701 Pointsself.performSegueWithIdentifier("signInView", sender: self)
piquussnsx
2,701 PointsSo to start answering your question, you should have a segway between two view controllers, a segway is a link between two controllers. To create go to your storyboard file, press the ctrl button on your keyboard, click on the view related to the code before, hold the click and select the target view controller.
Michael Kantor
2,183 PointsHow would I programmatically switch to one of the tabs?
piquussnsx
2,701 Pointswith performSegueWithIdentifier
Michael Kantor
2,183 PointsCould you show me an example? I can't figure out how to access that..
Michael Kantor
2,183 PointsMichael Kantor
2,183 Pointsthe view name is the storyboard id?
piquussnsx
2,701 Pointspiquussnsx
2,701 PointssignInView is the name of the segway you make in the storyboard.
Michael Kantor
2,183 PointsMichael Kantor
2,183 PointsAnd its suffixed with View ?