我開發有連接的TabBar控制器和附着的TabBar控制器一些其他的ViewController導航控制器應用程序登錄後,如下圖所示的:如何回到主頁或前視圖 - 控制在迅速3
現在我想告訴用戶的登錄頁面,只有當他們第二個選項卡,而不是在登錄點擊所以在第二個選項卡控制器,我有這樣的:
if let token = cookies["token"] {
//do something
} else {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "loginView")
self.tabBarController?.setViewControllers([vc!], animated: true)
}
在我LoginViewController,我會l ike在成功登錄後返回上一頁。我對該主題進行了一些研究。這是我嘗試過的。我試過這個:
let vc = self.storyboard?.instantiateViewController(withIdentifier: "minePage") as! MineViewController
self.tabBarController?.setViewControllers([vc], animated: true)
它調出頁面,但只顯示tabbar而不是導航欄了。我也試過這樣:
self.navigationController?.pushViewController(vc, animated: true)
它也帶來了用戶返回到「minePage」,但只顯示導航欄不使用TabBar。我也嘗試添加在故事板一退卷賽格瑞和功能在第一視圖控制器:
@IBAction func prepareForUnwindWithSegue(segue: UIStoryboardSegue){
}
,並試圖此:
self.dismiss(animated: true, completion: nil)
並沒有任何反應登錄後我的問題是
。- 故事板是否設置了添加登錄視圖的良好做法?一些stackoverflow的答案建議把登錄視圖放在一切之前。但只有部分應用程序需要登錄。所以它不適合。
- 如何返回上一頁或默認主頁(在我的情況下,第一個tabbar控制器視圖)?這兩種情況都需要在應用程序中。
謝謝。
沒有人有過這種情況嗎? – yang