问题
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 doesn
t 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?
回答1:
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.
来源:https://stackoverflow.com/questions/12480929/how-to-load-view-controller-without-button-in-storyboard