Swift / iOS. Remove few view controllers from navi

2019-04-09 13:02发布

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.

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

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

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

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

How can I get that result?

2条回答
狗以群分
2楼-- · 2019-04-09 13:22

You can go back to the initial view controller by calling UINavigationController.popToRootViewController(animated: Bool)

查看更多
爷、活的狠高调
3楼-- · 2019-04-09 13:24

You can remove view controller from navigation stack by function:

navigationController?.viewControllers.removeAtIndex(*index of view controller you wanna remove*)
查看更多
登录 后发表回答