从导航堆栈中删除几个视图控制器

从导航堆栈中删除几个视图控制器

本文介绍了斯威夫特/iOS.从导航堆栈中删除几个视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想要做的,我不确定这是正确的方法,所以请给我一个建议如何去做.

Here is what I want to do and I am not sure is it right approach, so please give me an advise how to do it.

我有带导航 VC 的初始 VC,我从它推第一个 VC,我从它推第二个 VC.

I have Initial VC with Navigation VC, from it I push First VC, from it I push Second VC.

接下来我介绍(来自第二个 VC 的 NavigationController)第三个 VC.

Next I present (from NavigationController of Second VC) Third VC.

现在我想从导航堆栈中删除第一个和第二个 VC.

And now I want to remove First and Second VCs from navigation stack.

之后我希望得到这样的结果:我解雇了第三个 VC,我看到了初始 VC

After that I expect to have such result: I dismiss Third VC and I see Initial VC

我怎样才能得到这个结果?

How can I get that result?

推荐答案

可以通过函数从导航栈中移除视图控制器:

You can remove view controller from navigation stack by function:

navigationController?.viewControllers.removeAtIndex(*index of view controller you wanna remove*)

这篇关于斯威夫特/iOS.从导航堆栈中删除几个视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 03:53