如何在情节提要中加载没有按钮的视图控制器? [英] How to load view controller without button in storyboard?

查看:29
本文介绍了如何在情节提要中加载没有按钮的视图控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加载没有按钮的视图控制器.我将标识符设置为 10 并尝试使用

I want to load view controller without button. I set the identifier to 10 and tried to use

if(...){ 
    //load ViewController2
    [[self storyboard] instantiateViewControllerWithIdentifier:@"10"];
}

但什么也没发生.

有了这个功能,它s 不也不起作用

with this function its doesnt work too

 UIViewController *vc = [[self storyboard] instantiateViewControllerWithIdentifier:@"10"];

[self.navigationController pushViewController:vc];

这是我的项目http://www.sendspace.com/file/kfjhd5

有什么问题吗?

推荐答案

调用 instantiateViewControllerWithIdentifier: 将实例化一个视图控制器,正如它所说的.而已.如果您想实际显示它,您必须使用一个变量并将其推送到您的视图控制器堆栈.

Calling instantiateViewControllerWithIdentifier: will instantiate a view controller, as it says. Nothing more. If you want to actually show it you have to use a variable and push it to your view controller stack.

UIViewController *vc = [[self storyboard] instantiateViewControllerWithIdentifier:@"10"];
[self.navigationController pushViewController:vc];

当然,您必须使用 UINavigationController 来做到这一点.

Of course you have to be using a UINavigationController to do this.

这篇关于如何在情节提要中加载没有按钮的视图控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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