Lance Samaria Lance Samaria - 18 days ago 6x
iOS Question

UITabBarController child view controller reset -Swift2 iOS

I have a tabBarController with 2 tabs: tabZero and tabOne.

tabZero contains a navController and 2 child view controllers. viewControllerRed is the nav's root which has a button that pushes on viewControllerBlue.

viewControllerBlue has a button:

. When buttonPressed is tapped, the tab index is switched to tabOne via
self.tabBarController.selectedIndex 1

My problem is after the switch, if I press tabZero viewControllerBlue is still showing. How do I reset to the nav's root vc (viewControllerRed) after using pressing the buttonPressed in viewControllerBlue?

I can't use
because there are 2 transitions happening at once. The first is I'm changing the tabBar index and the other is I the root vc reset. I need the reset to happen in the background.


You can perform the pop function in a delay without animation.

[self.navigationController performSelector:@selector(popToRootViewController) withObject:nil afterDelay:1];


Poptorootviewcontroller with delay