快速显示或打开或导航至UITabBarController窗体Viewcontroller之类的登录页面

时间:2018-12-06 14:06:17

标签: swift xcode uitabbarcontroller

我的要求非常简单,我是ios开发的新手, 我想在成功登录后显示UITabBarController

@IBAction func LoginAction(_ sender: Any) {
//correct me here!
 let storyBoard = UIStoryboard(name: "Main", bundle: nil)
        let tabbar:UITabBarController? = (storyBoard.instantiateViewController(withIdentifier: "LiveViewController") as? UITabBarController)
            navigationController?.pushViewController(tabbar!, animated: true)

}  

main.storyBoard故事板:
enter image description here

1 个答案:

答案 0 :(得分:1)

navigationController?

nil

navigationController?.pushViewController(tabbar!, animated: true)

您需要

let tabbar = storyboard!.instantiateViewController(withIdentifier: "LiveViewController") as! UITabBarController
let nav = UINavigationController(rootViewController: tabbar)
nav.isNavigationBarHidden = true
(UIApplication.shared.delegate as! AppDelegate).window!.rootViewController = nav