我有一系列在导航控制器下管理的视图。有没有办法以编程方式(在iOS5 +中)跳转(推/弹)到不同的视图?例如,我有
NavigationController-> RootViewController-> DetailViewController1-> DetailViewController2-> DetailViewController3
我怎么能从RootViewController跳转到DetailViewController3,然后跳回到DetailViewController1?
感谢。
答案 0 :(得分:1)
你可以尝试这样的事情。
从故事板中获取您的VC。 (您必须在故事板中设置标识符)
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *DetailViewController1 = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController1Identifier"];
UIViewController *DetailViewController3 = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController3Identifier"];
按照您需要的方式推送VC。
[self.navigationController pushViewController:(DetailViewController1) animated:YES];
[self.navigationController pushViewController:(DetailViewController3) animated:YES];
现在,当您按“返回”时,您将看到DetailViewController1。