I've an app where there are more than 10 ViewControllers
and there is a MenuViewController
Which is triggered by all the ViewControllers
. And MenuViewController
Triggers all ViewControllers
. So in app I will not unwind a Segue but keep on triggering the segues.
Scheme:
Does it give any side effect like out of memory or app hanging kind of? Will it be fine if I keep on triggering segues without unwinding them?
Question no 2 is
When I trigger
VC1
toMenuVC
menuVC
toVC1
VC1
toMENUVC
menuVC
toVC1
Now I'll Trigger a segue from vc1 to vc2 and the segue opens two times cause there are two vc1 's which are present in Segue tree Its the problem
Somebody Please Help ???
My Storyboard pic
You'll eventually run out of memory if you keep pushing new view controllers on the navigation stack without removing the previous ones. If you never want to pop back to a previous view controller, you can remove the complete navigation history after the push transition has finished in each view controllers viewDidAppear:
:
- (void)viewDidAppear {
[super viewDidAppear];
self.navigationController.viewControllers = @[self];
}
Alternatively, you can put this logic in a central place by setting your navigation controller's delegate
and implementing navigationController:didShowViewController:animated:
:
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
navigationController.viewControllers = @[navigationController.viewControllers.lastObject];
}
E.g. your app delegate could be the navigation controller's delegate
.