How to load view controller without button in storyboard?

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"]; }

but nothing happens.

with this function its doesnt work too

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

here is my progect http://www.sendspace.com/file/kfjhd5

whats a problem?

Answer1:

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];

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

人吐槽 人点赞

Recommend

Comment

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:How to load view controller without button in storyboard?