如何popToRootViewController在navigationController堆栈上有多个viewController(2),并且只显示一个过渡?
例如VC A将VC B、C推到导航栈上。现在我想让C到A有一个平滑的动画过渡,而完全不显示B。
我试过很多方法,但总是看到B。
例如,我试过。
self.navigationController?.viewControllers.removeLast()
self.navigationController?.popToRootViewController(animated: true)
我试了很多方法,但总是看到B
func popBack<T: UIViewController>(toControllerType: T.Type) {
if var viewControllers: [UIViewController] = self.navigationController?.viewControllers {
viewControllers = viewControllers.reversed()
for currentViewController in viewControllers {
if currentViewController .isKind(of: toControllerType) {
self.navigationController?.popToViewController(currentViewController, animated: true)
break
}
}
}
}
以及用动画false弹出,然后用动画true弹出,但我总是看到B. 有很多SO的线程,我尝试了更多的东西,不仅仅是我上面说的。