I have 6 subclassed UIViewControllers connected with push segues with identifiers.
They go A>B>C>D>E>F. I am unable to find a way how to implement button in the controller A which would automatically stack all controllers up to controller F and display F controller. Stacking should be done in UINavigationController
instance, not through(void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
, because if I use setViewControllers
method, then I lose segue identifiers. Ty!
You should be able to do it with pushViewController:animated:
, like this:
// 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];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With