if(!isUserLoggedIn){
var loginViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("loginView") as! LoginViewController
window!.rootViewController = loginViewController
window!.makeKeyAndVisible()
}else{
var mainViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("mainView") as! FirstViewController
var myDealsViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("myDealsViewController") as!MyDealsViewController
var settingsViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("settingsView") as! SettingsViewController
var centerNav = UINavigationController(rootViewController: mainViewController) as UINavigationController
var myDealNavController = UINavigationController(rootViewController: myDealsViewController) as UINavigationController
let controllers = [centerNav,myDealNavController,settingsViewController]
tabBarController.viewControllers = controllers
window!.rootViewController = tabBarController
window!.makeKeyAndVisible()
}
以上代码正常运行,但即使单击中心标签栏项目,该应用也未显示标签栏项目。
答案 0 :(得分:1)
用以下代码替换代码行:
var myDealNavController = mainStoryBoard.instantiateViewControllerWithIdentifier("myDealNavController") as! UINavigationController
将“myDealNavController”设置为故事板中UINavigationController的标识符。