通过代码实现 Segue [英] Segue implementation via code

查看:29
本文介绍了通过代码实现 Segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是IOS新手.我正在故事板中创建授权场景.它由textFields(用户名、密码)和按钮(登录、注册)组成.当登录名和密码正确时,UIAlertView 会显示成功"文本.在此之后,应显示 MainScene.但是我无法在 Interface Builder 中创建 segue.我如何通过代码实现它?

解决方案

您可以这样做:

  1. 创建一个从源 ViewController(不是控件)到目标 ViewController 的 Segue.

  2. 在 Interface Builder 故事板文件上为 Segue 命名.

  3. 以编程方式执行 Segue:[self performSegueWithIdentifier:@"MySegueIdentifier" sender:nil];

<块引用>

注意:要从 ViewController 创建 Segue,请按住 control 并像往常一样拖动源 ViewController 而不是控件做,到目标控制器.

I am a newbie in IOS. I am creating an Authorization Scene in a Storyboard. It consists of textFields (username, password) and buttons (Log In, Sign Up). When login and password are correct, UIAlertView is displayed with text "Success". After this, MainScene should be displayed. But I can't create a segue in Interface Builder. How can I implement it via code?

解决方案

Here is what you can do:

  1. Create a Segue from your source ViewController (not control) to the destination ViewController.

  2. Give Segue a name on the Interface Builder storyboard file.

  3. Perform Segue programmatically: [self performSegueWithIdentifier:@"MySegueIdentifier" sender:nil];

Note: To create Segue from a ViewController, hold control down and drag source ViewController instead of a control as you would normally do, to the destination controller.

这篇关于通过代码实现 Segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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