我有6个子类UIViewControllers与带有标识符的push segues连接。
< B> C> C> D> F> F。我无法找到如何在控制器A中实现按钮的方法,该按钮会自动将所有控制器堆叠到控制器F并显示F控制器。堆叠应该在UINavigationController
实例中完成,而不是通过(void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
,因为如果我使用setViewControllers
方法,那么我将丢失segue标识符。 TY!
答案 0 :(得分:7)
您应该可以使用pushViewController:animated:
执行此操作,如下所示:
// This method belongs to view controller A class
-(void)pushToF {
// I am assuming that A is already in the navigation controller
UINavigationController *nav = self.navigationController;
UIViewController *b =[self.storyboard instantiateViewControllerWithIdentifier:@"B"];
[nav pushViewController:b animated:NO];
UIViewController *c =[self.storyboard instantiateViewControllerWithIdentifier:@"C"];
[nav pushViewController:c animated:NO];
... // And so on, until F
UIViewController *f =[self.storyboard instantiateViewControllerWithIdentifier:@"F"];
// You can push the last one with animation, so that end users would see it
[nav pushViewController:f animated:YES];
}