更新时间:2023-12-03 20:35:34
好的,我已经弄明白了。我已经将 UIButton
中的segue定义为下一个 UIViewController
。按照这种方式定义,没有办法有条件地执行segue。
Ok, I have figured it out. I had defined a segue from a UIButton
to the next UIViewController
. As defined in this manner, there is no way to conditionally execute the segue.
我没有把segue放在按钮上,而是从第一个 UIViewController 到另一个 UIViewController
。这定义了segue,但不与它相关联。从那里我可以简单地调用 performSegueWithIdentifier:sender:
当我想要执行segue时(在我的情况下是异步任务完成时)。
Instead of putting the segue on the button, I made a segue from the first UIViewController
to the other UIViewController
. This defines the segue, but associates no action with it. From there I can simply call performSegueWithIdentifier:sender:
when I want that segue to execute (in my case being when the async task is complete).
这对我来说的主要优势在于IB维持其结构。
The main advantage of this for me is that IB maintains its structure.
非常感谢@cli_hlt指出我正确的方向( +1)。
Big thanks to @cli_hlt for pointing me in the right direction (+1).