我的要求非常简单,我是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故事板:
答案 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