Swift / iOS. Remove few view controllers from navigation stack

时光毁灭记忆、已成空白 提交于 2019-12-21 17:49:42

问题


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?


回答1:


You can remove view controller from navigation stack by function:

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



回答2:


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



来源:https://stackoverflow.com/questions/43403873/swift-ios-remove-few-view-controllers-from-navigation-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!