我在以編程方式打開新的View Controller時遇到此問題。選項卡欄不顯示在導航控制器內的視圖控制器上
let controller = self.storyboard?.instantiateViewController(withIdentifier: "overViewScreen") as! OverviewViewController
controller.user = self.userObject
let navigationController = UINavigationController(rootViewController: controller)
self.present(navigationController, animated: true, completion: nil)
我的項目結構: storyboard
在我的故事板標籤欄顯示到視圖控制器(上右表),但是當我運行的應用程序,它看起來像這樣: enter image description here
我希望你們能幫助我! 謝謝。
你的意思是這樣嗎?讓tabBarController = self.storyboard?.instantiateViewController(withIdentifier:「TabBarController」) self.present(tabBarController!,animated:true,completion:nil) –
或類似的東西: let tabVC = UIStoryboard(name:「NameOfYourStoryboard」, bundle:Bundle.main).instantiateInitialViewController()as! UITabBarController let navVc = tabVC.viewControllers.first as! UINavigationController let vc = navVc.viewControllers.first as! LoginViewController vc.incorrectAuthorization = SettingsAuthorizationMethod.fingerprint vc.user = self.userObject 存在(navController,動畫:真,完成:無) –
所以現在我有:讓tabBarController = self.storyboard .instantiateInitialViewController()的?! UITabBarController 讓navVc = tabBarController.childViewControllers.first as! UINavigationController let vc = navVc.childViewControllers.first as! OverviewViewController vc.user = self.userObject self.present(navVc,animated:true,completion:nil)。錯誤:無法將LoginViewController投射到UITabBarController –