How to perform conditional segue

南笙酒味 提交于 2019-12-04 06:15:13

问题


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

In the button click action, I have performSegue(withIdentifier:sender:) 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?


回答1:


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.



来源:https://stackoverflow.com/questions/40002607/how-to-perform-conditional-segue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!