[英]How to remove a ViewController from navigation stack and not have the option to go back to it-Swift
我有一個登錄頁面,如果登錄成功,用戶將被帶到登陸viewController(VC)。 我有一個navigationController。 我彈出登錄VC並推入登陸VC。 我遇到的問題是,如導航控制器上的向左按鈕所指示的那樣,登錄VC仍保留在堆棧中,該導航控制器將您導航回登錄頁面。 如何從堆棧中完全刪除登錄VC,以便導航控制器在用戶登錄后無法將其導航回去?
self.navigationController?.popViewController(animated: true)
let landingPage = self.storyboard?.instantiateViewController(withIdentifier: "landingPage") as!
LandingViewController
self.navigationController?.pushViewController(landingPage, animated: true)
您可以使用setViewControllers
方法來設置堆棧,如下所示:
self.navigationController?.setViewControllers([landingPage], animated: true)
您也不需要先彈出登錄視圖控制器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.