2

When a user taps my button, I would like to have a control flow that resembles:

@IBAction func confirmPurchase(sender: AnyObject) {

    if blue == true {
        let mainTabController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("MainTabBarController")
        self.presentViewController(mainTabController, animated: true, completion: nil)
    } else {
        perform an unwind segue
    }
}

I am looking for method to call unwind segue in code. How is this achieved?

ray
  • 102
  • 1
  • 8

1 Answers1

4

You can call an unwind segue programmatically with performSegueWithIdentifier.
Instead of wiring the unwind segue from your button, you wire it from the viewController icon at the top of the view controller to the exit icon.

See the second part of this answer to see how it needs to be wired in the Storyboard:

How to wire an unwind segue to be called programmatically

Community
  • 1
  • 1
vacawama
  • 133,454
  • 26
  • 238
  • 261