如何执行有条件的搜索 [英] How to perform conditional segue

查看:92
本文介绍了如何执行有条件的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过IB创建了segue.当单击buttonA时,将切换到viewB.

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

在按钮单击动作中,我将performSegue(withIdentifier:sender:)包裹在一个条件中.我希望仅当条件为真时才发生segue.

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.

但是,一旦用户单击该按钮,就会在条件运行之前进行检测.在仍然使用IB中定义的segue标识符的同时,以编程方式进行转换的最佳方法是什么?

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?

推荐答案

您已经从UIButtonviewController创建了segue,这是segue在条件执行之前发生的原因.而不是从情节提要中删除该序列,然后从您的ViewControllerDestinationViewController中创建另一个.

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.

这篇关于如何执行有条件的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆