问题标签 [popviewcontrolleranimated]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
swift - 如何从另一个类做 popViewController?
我的应用程序有一个 TabBarController。每个 tabBarItem 都与嵌入在 NavigationController 中的 ViewController 相关。
在第一个 tabBarItem 并选择另一个 tabBarItem 时,我想在移动到所选 ViewController 之前做一些事情。因此,我为我的 tabBarController 创建了一个类并将其设为 UITabBarControllerDelegate。
我想要做的是用两个按钮显示一个警报;按钮 A 取消移动到选定的 viewController,按钮 B 让移动发生。
我的问题是,当按下按钮 B 时,我想 popToRootViewController。我给了 navigationController 一个 storyboardID 并尝试实例化它,如下所示。
一切都按预期工作,但 popToRootViewController 似乎没有发生;当再次选择第一个 tabBarItem 时,我们离开该项目时处于“活动”状态的同一 viewController 仍在显示。
我检查了我想要弹出的 viewController 实际上在导航堆栈中,并且 navContr != nil。
我错过了什么?