// 跳转指定控制器
func jumpDesignatedController() {
// 方法一(跳转指定控制器)
let mineVC = MyAcountAuthViewController()
var targetVC : UIViewController!
for controller in self.navigationController!.viewControllers {
if controller.isKind(of: mineVC.classForCoder) {
targetVC = controller
}
}
if targetVC != nil {
self.navigationController?.popToViewController(targetVC, animated: true)
}
// 方法二(跳转根控制器)
self.navigationController?.popToRootViewController(animated: true)
// 方法三(返回到根界面的某个控制器)
self.navigationController?.tabBarController?.hidesBottomBarWhenPushed = false
self.navigationController?.tabBarController?.selectedIndex = 0 // (第一个控制器)
self.navigationController?.popToRootViewController(animated: true)
// 方法四(返回两级界面)
if (self.navigationController?.viewControllers.count)! >= 2 {
guard let vc = self.navigationController?.viewControllers[1] else { return }
self.navigationController?.popToViewController(vc, animated: true)
}
}
原地址:https://www.jianshu.com/p/f0e69f325809
感谢原作者