let tabBarController = UITabBarController()
let VC1 = ConstDetailViewController()
VC1.tabBarItem.image = UIImage(named: "Home.Re.png")
let VC1Navigation = UINavigationController(rootViewController: VC1)
let VC2 = LeaderboardViewController()
VC2.tabBarItem.image = UIImage(named: "search3.png")
let VC2Navigation = UINavigationController(rootViewController: VC2)
let VC3 = MapViewViewController()
VC3.tabBarItem.image = UIImage(named: "graphRe.png")
let VC3Navigation = UINavigationController(rootViewController: VC3)
let VC4 = UserProfileViewController()
VC4.tabBarItem.image = UIImage(named: "UserRe.png")
let VC4Navigation = UINavigationController(rootViewController: VC4)
let loginVC = ConstituencyViewController()
let VC5Navigation = UINavigationController(rootViewController: loginVC)
let controllers = [VC1Navigation, VC2Navigation,VC3Navigation,VC4Navigation]
tabBarController.viewControllers = controllers
self.window!.backgroundColor = UIColor.white
self.window?.rootViewController = VC5Navigation
self.window!.makeKeyAndVisible()
我已经在我的appdelegate中配置了标签栏。但是现在我缺少标签栏。它在选项卡栏位置显示空白。请帮助我解决问题。
最佳答案
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let tabBarController = UITabBarController()
let VC1 = UIViewController()
VC1.tabBarItem.image = UIImage(named: "Home.Re.png")
let VC1Navigation = UINavigationController(rootViewController: VC1)
let VC2 = UIViewController()
VC2.tabBarItem.image = UIImage(named: "search3.png")
let VC2Navigation = UINavigationController(rootViewController: VC2)
let VC3 = UIViewController()
VC3.tabBarItem.image = UIImage(named: "graphRe.png")
let VC3Navigation = UINavigationController(rootViewController: VC3)
let VC4 = UIViewController()
VC4.tabBarItem.image = UIImage(named: "UserRe.png")
let VC4Navigation = UINavigationController(rootViewController: VC4)
let loginVC = UIViewController()
let VC5Navigation = UINavigationController(rootViewController: loginVC)
let controllers = [VC1Navigation, VC2Navigation,VC3Navigation,VC4Navigation]
tabBarController.viewControllers = controllers
self.window!.backgroundColor = UIColor.white
self.window?.rootViewController = tabBarController //TabBarController
self.window!.makeKeyAndVisible()
return true
}
关于ios - 在Swift iOS中的appdelegate中配置Tabbar Controller 后,我丢失了Tabbar,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41586856/