通过代码实现 Segue [英] Segue implementation via code
问题描述
我是IOS新手.我正在故事板中创建授权场景.它由textFields(用户名、密码)和按钮(登录、注册)组成.当登录名和密码正确时,UIAlertView 会显示成功"文本.在此之后,应显示 MainScene.但是我无法在 Interface Builder 中创建 segue.我如何通过代码实现它?
您可以这样做:
创建一个从源 ViewController(不是控件)到目标 ViewController 的 Segue.
在 Interface Builder 故事板文件上为 Segue 命名.
以编程方式执行 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:
Create a Segue from your source ViewController (not control) to the destination ViewController.
Give Segue a name on the Interface Builder storyboard file.
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屋!