kevinabraham
kevinabraham

Reputation: 1427

How to perform a segue directly from the first navigation controller in a storyboard in swift?

I need to perform a segue when loading the storyboard from the navigation controller. Im using UpdatesViewController().segueToPerform("SegueIdentifier.forcedUpgrade") in the viewDidLoad() function but it doesn't trigger at all.

Storyboard

Upvotes: 0

Views: 216

Answers (2)

kevinabraham
kevinabraham

Reputation: 1427

Solved this by adding in another view controller and then sending the segues from there.

Upvotes: 0

Chris
Chris

Reputation: 147

I am not sure if the method you are using is correct.

how I load my other viewcontroller is by checking. For example, once the app loads, it checks if a user is logged in, if not it will push the signin view controller

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    //forexample using firebase
    FIRAuth.auth()?.addAuthStateDidChangeListener({ (auth, user) in
        if let user = user {


        } else {

            // assign storyboard to the name of your storyboard
            let storyboard = UIStoryboard(name: "Main", bundle: nil)

            //instantiate whichever controller in the storyboard
            let signInViewController = storyboard.instantiateViewControllerWithIdentifier("SignIn")

            //present viewcontroller
            self.presentViewController(signInViewController, animated: true, completion: nil)

        }
    })



}

Upvotes: 1

Related Questions