Is there any way to push a view controller to the navigation controller without stacking it?
Wanted behavior (stack representation):
[VC1[VC2]] -> Push VC3 from VC2 -> [VC1[VC3]]
Yeah, just pop the other one before (without animating this one) like this:
[navController popViewControllerAnimated:NO]
[navController pushViewController:VC3 animated:YES]
Or go for option 2, which is more general: Replace the viewControllers property:
NSArray *newControllers = @[VC1, VC3];
[navController setViewControllers:newControllers animated:YES];
or...
NSArray *newControllers = @[navController.viewControllers[0], VC3];
[navController setViewControllers:newControllers animated:YES];
I would make use of UINavigationController's method:
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
That way you can do this:
UINavigationController *navigationController = [self navigationController];
[navigationController setViewControllers:@[navigationController.viewControllers[0], VC3] animated:YES];
This will give you a push animation to the new view controller (VC3).
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