dimanche 10 mai 2015

How to present a new viewController without a action?

Im trying to push to a new viewController if a user is logged in, but I don't really understand were it fails or how the best why of presenting a viewController.

how can i set the window hierarchy? or push a viewController programmatically without a button action?

    if (FBSDKAccessToken.currentAccessToken() != nil)
    {
        returnUserData()
        var storyboard: UIStoryboard = UIStoryboard(name:"Main", bundle:nil)

        var vc: UINavigationController = storyboard.instantiateViewControllerWithIdentifier("loggedInViewController") as! UINavigationController

        self.presentViewController(vc, animated: true, completion: nil)
        // User is already logged in, do work such as go to next view controller.
    }

error message:

User Logged In 2015-05-10 16:35:18.010 noscrubs[32134:43488091] Warning: Attempt to present on whose view is not in the window hierarchy!

thanks a lot for any help I really want to get into the flow, so all pointers are appreciated!

Aucun commentaire:

Enregistrer un commentaire