简体   繁体   English

UITabBarController子视图控制器重置-Swift2 iOS

[英]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.

相关问题 当LoginView是初始视图时,在情节提要中子类化UITabBarController [Swift2,Xcode 7] - Subclassing UITabBarController in storyboard when LoginView is initial view [Swift2, Xcode 7] UITabBarController选项卡模式演示-Swift2 OS - UITabBarController Tab Modal Presentation -Swift2 OS UINavigation控制器与iOS Swift中的SWRevealViewController的UITabbarcontroller问题 - UINavigation controller to UITabbarcontroller issue with SWRevealViewController in iOS Swift 在SWIFT 3中访问UITabBarController的“更多…”视图控制器 - Access the 'More…' View Controller of UITabBarController in SWIFT 3 在 Swift 5 中以编程方式在 UITabBarController 中显示视图控制器 - Displaying View Controller within a UITabBarController programatically in Swift 5 允许一个视图控制器在swift2 xcode7中旋转景观 - Allow one view controller to rotate landscape in swift2 xcode7 iOS 6到Swift2更新滑块 - IOS 6 to Swift2 update Slider 如何使用Swift在iOS 8中正确添加子视图控制器 - How To Properly Add Child View Controller in iOS 8 With Swift Swift iOS - 当作为子视图控制器添加到另一个视图控制器时,是否应该在子视图控制器中调用 Deinit? - Swift iOS -Should Deinit get called inside child View Controller when added as a child to another View Controller? 如何从其自己的子视图控制器中删除模态uitabbarcontroller - How to dismiss modal uitabbarcontroller from its own child view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM