在Storyboards中成功登录后执行segue [英] Perform segue after Login successful in Storyboards

查看:84
本文介绍了在Storyboards中成功登录后执行segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2 UITextFields ,其中一个用于登录,另一个用于密码。

I have 2 UITextFields, one of them for Login and the another for the Password.

仅当登录是成功的,我想用推送执行 Segue 到另一个查看控制器。但是当我触摸按钮时,直接将视图推送到另一个视图而不检查条件。

Only if the Login is "succesful", I want to perform the Segue with Push to another View Controller. But when I touch the button, directly the View push to the Another View without check the Condition.

在StoryBoard中我从UIButton拖动到我想要推送的视图控制器,用于使用推送选项创建segue。

In StoryBoard I drag from the UIButton to the View Controller I want to push, for creating the segue with push option.

这是我的代码:

- (IBAction)buttonLogin:(id)sender {
    if (([self.textFieldLogin.text isEqualToString:@"User"]) && ([self.textFieldPassword.text isEqualToString:@"1515"])){

       [self performSegueWithIdentifier:@"SegueLogin" sender:self];

    }else{
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"User wrong"
                                                      message:@"Fill up again the user info"
                                                     delegate:nil
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:@"Cancel", nil];
        [alert show];
    }
}


推荐答案

你需要将segue从整个 UIViewController 拖到下一个 UIViewController ,即你不应该专门连接 UIButton (或任何相关的IBOutlet)到下一个 UIViewController 如果转换是有条件的。

You need to drag the segue from the overall UIViewController to the next UIViewController, i.e. you shouldn't specifically connect the UIButton (or any IBOutlet for that matter) to the next UIViewController if the transition's conditional.

如下所示:

这篇关于在Storyboards中成功登录后执行segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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