如何将两个视图控制器连接到故事板中的一个按钮? [英] How to connect two view controllers to one button in storyboard?

查看:123
本文介绍了如何将两个视图控制器连接到故事板中的一个按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,视图控制器中有一个按钮(我们称之为主视图控制器)。我想要的是:如果它满足某个条件,当我按下按钮时,segue将导致View Controller A;如果没有,当我按下按钮时,它将导致View Controller B.
但似乎一个按钮只能有一个segue,所以我想知道我想要的是否可以在故​​事板中实现? ??
提前致谢!!!

Up to now, there is a button in a view controller (let's call it Main View Controller). What I want is: if it satisfies a certain condition, when I press the button, the segue would lead to View Controller A; if not, when I press the button, it would lead to View Controller B. But it seems that one button can only have one segue from it, so I wonder whether what I want is possible to be achieved in storyboard??? Thanks in advance!!!

如果这个问题对你来说太基本了,我很抱歉。我仍然是iOS编程的首选。

If this question is too basic for you, I am so sorry. I am still a very starter in iOS programming.

推荐答案

您需要从viewController本身创建一个segue到目的地。您可以为每个viewController执行此操作并为其提供适当的标识符。

You need to create a segue from the viewController itself to the destination. You can do this for each viewController and give them appropriate identifiers.

然后用 IBAction 连接你的按钮并确定哪个segue到执行

Then you hook up your button with an IBAction and decide which segue to perform

这篇关于如何将两个视图控制器连接到故事板中的一个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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