4thSpace 4thSpace - 1 year ago 90
Swift Question

How to perform conditional segue

I've created a segue through IB. When buttonA is clicked, a transition to viewB will occur.

In the button click action, I have

wrapped in a condition. I want the segue to occur only if the condition is true.

However, once the user clicks the button, the segue happens before the condition is even run. What is the best way to transition programmatically while still using segue identifiers defined in IB?

Answer Source

You have created segue from the UIButton to a viewController that is the reason segue happens before the execution of condition. Instead of that remove that segue from storyboard and create another from your ViewController to DestinationViewController.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download