定义“通用”在Interface Builder中使用segue [英] Defining a "generic" segue in Interface Builder

查看:237
本文介绍了定义“通用”在Interface Builder中使用segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解如何通过右键单击控件来创建一个segue,让我们说一个按钮,并将其拖动到故事板中的视图控制器。



我想要做的是创建一个不依赖于控件的segue,并且必须以编程方式调用,以便我可以执行以下操作:

   - (void)viewDidLoad 
{
if(condition)
{
[self performSegueWithIdentifier:@identifiersender:self];
}
}

同时仍然在Interface Builder中定义标识符segue 。这可能吗?

解决方案

您可以从源视图控制器按住Ctrl键拖动到另一个场景。您可以使用场景底部的视图控制器对象来执行此操作。



然后当然给它提供适当的标识符,然后上面的代码应该可以正常工作。 / p>

希望有所帮助。


I understand how to create a segue in XCode 4.2 by right clicking a control, let's say a button, and dragging it to a view controller in the storyboard.

What I would like to do is create a segue that is not tied to a control, and must be invoked programmatically so I can do something like this:

- (void)viewDidLoad
{
    if (condition) 
    {
        [self performSegueWithIdentifier: @"identifier" sender: self];
    }
}

while still defining the "identifier" segue within Interface Builder. Is this possible?

解决方案

You can ctrl-drag from the source view controller to the other scene. You can use the view controller object at the bottom of the scene to do this.

Then of course give it the appropriate identifier and then your code above should work fine.

Hope that helps.

这篇关于定义“通用”在Interface Builder中使用segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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