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 trial

iOS

Murat KAYA
Murat KAYA
10,127 Points

segue after login with facebook swift

I'm trying to push another view after login succesfully login with facebook.But I couldn't realize how can I do that.Can anybody Help me ?

3 Answers

Murat KAYA
Murat KAYA
10,127 Points

Okey I figured out how can I do that

If you have configured a segue, use following code

self.performSegueWithIdentifier("identifier", sender: self)

If you want to initialize a viewcontorller using StoryBoardId, use following code

let viewController =  self.storyboard.instantiateViewControllerWithIdentifier("StoryBoardID") as? UIViewController
self.presentViewController(viewController, animated: true, completion: nil)
Murat KAYA
Murat KAYA
10,127 Points
if user.objectID != nil {
            let storyboard = UIStoryboard(name: "loginView", bundle: nil)
            let secondView =  storyboard.instantiateViewControllerWithIdentifier("mainView") as UIViewController
            self.presentViewController(secondView, animated: true, completion: nil)
        }

and it didn't work

Glad you figured it out, Murat KAYA.

For anyone else doing something similar, I did a google search for:

let storyboard = UIStoryboard(name: " "self.presentViewController(secondView, animated: true, completion: nil)" "storyboard.instantiateViewControllerWithIdentifier"

..and only came up with 15 results of which the most interesting was this StackOverFlow thread:

http://stackoverflow.com/questions/24167073/how-to-transition-to-a-new-view-controller-with-code-only-using-swift