使用此代码并享受:NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers];// [navigationArray removeAllObjects]; // This is just for remove all view controller from navigation stack.[navigationArray removeObjectAtIndex: 2]; // You can pass your index hereself.navigationController.viewControllers = navigationArray;[navigationArray release];希望这会帮助你。编辑:Swift代码guard let navigationController = self.navigationController else { return }var navigationArray = navigationController.viewControllers // To get all UIViewController stack as ArraynavigationArray.remove(at: navigationArray.count - 2) // To remove previous UIViewControllerself.navigationController?.viewControllers = navigationArray
斯威夫特3&4/5self.navigationController!.viewControllers.removeAll()self.navigationController?.viewControllers.remove(at: "insert here a number")斯威夫特2.1移除所有:self.navigationController!.viewControllers.removeAll()从索引处删除self.navigationController?.viewControllers.removeAtIndex("insert here a number")还有很多其他可能的动作,例如removeFirst,range等。