1.跳到根控制器
let nav:UINavigationController = sliderVC.rightVC as! UINavigationController;
nav.popToRootViewController(animated: false);
2.跳到指定控制器
let story = UIStoryboard.init(name: "Main", bundle: nil)
let VC:searchVC = story.instantiateViewController(withIdentifier: "searchVC") as! searchVC;
var arrM = NSMutableArray(array: self.navigationController?.viewControllers ?? []);
arrM.removeLastObject();
arrM.add(VC);
self.navigationController?.setViewControllers(arrM as! [UIViewController], animated: true);
参考博客:
链接: iOS - 跳转到指定的控制器