简体   繁体   中英

Unwinding a Segue effecting the app?

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 to MenuVC

menuVC to VC1

VC1 to MENUVC

menuVC to VC1

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];
}

Eg your app delegate could be the navigation controller's delegate .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM