如何执行segue [英] how to perform a segue

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

问题描述

我想实现一个按钮来显示另一个视图。我在Storyboard&中定义了目标ViewController。创建了一个segue(类型为push)并给它一个标识符。

I would like implement a button to show another view. I have defined the destination ViewController in Storyboard & created a segue (of type push) and gave it an identifier.

在我的根视图控制器中

一些方法...

        UIButton *btn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [btn addTarget:self action:@selector(showDetailView:) forControlEvents:UIControlEventTouchUpInside];

- (IBAction)showDetailView:(id)sender {
    [self performSegueWithIdentifier:@"ShowDetail" sender:sender];
}

但它没有做任何事情。我听说Segue是一个对象。我是否需要在根视图控制器类中引用它/合成它?任何提示将不胜感激。谢谢。

however it doesn't do anything. I hear a Segue is an object. do I need to have a reference to it / synthesize it in my root view controller class? Any tip would be appreciated. Thank you.

推荐答案

编辑:


确保您的根视图控制器是嵌入式的在导航控制器中。如果不是,请在情节提要设计器中选择视图控制器,然后在菜单中选择编辑器 - >嵌入 - >导航控制器。


Make sure your root view controller is embedded in a navigation controller. if it isn't, select your view controller in the storyboard designer and choose Editor->Embed In->Navigation Controller in the menu.

原文:


仔细检查标识符(故事板代码)并尝试将发件人设置为 self 。如果这不起作用,你可以自己在代码中创建一个Segue对象。

Original:
Double-check the Identifier (storyboard-code) and try setting sender to self. If that doesn't work you can create a Segue object yourself in code.

这篇关于如何执行segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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