在swift ios中的appdelegate中配置tabbar控制器后,我错过了我的tabbar

时间:2017-01-11 09:19:28

标签: ios iphone swift3 uitabbarcontroller

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中配置了标签栏。但是现在我错过了我的标签栏。它在标签栏的位置显示一个空格。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

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
}