[英]UITabBarController child view controller reset -Swift2 iOS
I have a tabBarController with 2 tabs: tabZero and tabOne. 我有一个带有2个选项卡的tabBarController:tabZero和tabOne。
tabZero contains a navController and 2 child view controllers. tabZero包含一个navController和2个子视图控制器。 viewControllerRed is the nav's root which has a button that pushes on viewControllerBlue.
viewControllerRed是导航的根,该根具有一个按下viewControllerBlue的按钮。
viewControllerBlue has a button: buttonPressed
. viewControllerBlue有一个按钮:
buttonPressed
。 When buttonPressed is tapped, the tab index is switched to tabOne via self.tabBarController.selectedIndex 1
点击buttonPressed时,选项卡索引通过
self.tabBarController.selectedIndex 1
切换到tabOne。
My problem is after the switch, if I press tabZero viewControllerBlue is still showing. 我的问题是切换后,如果按tabZero,则viewControllerBlue仍然显示。 How do I reset to the nav's root vc (viewControllerRed) after using pressing the buttonPressed in viewControllerBlue?
按下viewControllerBlue中的buttonPressed后,如何重置到导航的根vc(viewControllerRed)?
I can't use popToRootViewController
because there are 2 transitions happening at once. 我不能使用
popToRootViewController
因为一次有2个转换发生。 The first is I'm changing the tabBar index and the other is I the root vc reset. 第一个是我要更改tabBar索引,第二个是我要重置vc。 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];
or 要么
Poptorootviewcontroller with delay 带有延迟的Poptorootviewcontroller
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.