ios-将一个UIButton连接到2个segue [英] ios - Connect one UIButton to 2 segues

查看:69
本文介绍了ios-将一个UIButton连接到2个segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIButton,我正在尝试将其连接到两个segue.使用哪种segue取决于许多条件.

I have a UIButton and I am trying to connect it to two segues. Which segue is used depends on a number of conditions.

例如,当按下UIButton(标题为"next")时,

For example, when the UIButton (with title "next") is pressed,

if(条件1),然后转到屏幕A.否则转到屏幕B.

我相信我的代码是正确的(无论如何我都包含了它),但是问题是在情节提要视图中,我只能使用segue将一个按钮连接到一个视图控制器.我该如何解决?

I believe my code is correct (I have included it anyways), but the problem is that in the storyboard view, I can connect one button to only one view controller using a segue. How do I fix this ?

这是我正在使用的代码-

Here's the code I'm using -

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
        if([[segue identifier]isEqualToString:@"nextButtonID"]){
            creditCardViewController *cvc = [segue destinationViewController];
        }
        else if([[segue identifier]isEqualToString:@"next2ButtonID"]){
            depositInfoViewController *divc = [segue destinationViewController];
        }
}

-(IBAction)nextClicked{
        if([accountType isEqualToString:@"patron"]){
            [self performSegueWithIdentifier:@"nextButtonID" sender:self];
        }
        else{
            [self performSegueWithIdentifier:@"next2ButtonID" sender:self];
        }
}

推荐答案

在情节提要面板窗口中,控制从视图底部的视图控制器图标拖动到目标视图控制器,并为segue提供一个标识符,并重复进行下一个搜索.

In the storyboard window, control drag from the view controller icon on the bottom of the view and drag it to the destination view controller, give the segue an identifier, and repeat for the next segue.

这篇关于ios-将一个UIButton连接到2个segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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