2015-09-01 93 views
0
override func viewDidAppear(animated: Bool) { 
    super.viewDidAppear(animated) 
    println("TabBar viewDidAppear") 
    self.checkForNewKey() 
    if freshLaunch == true { 
     freshLaunch = false 
     self.tabBar.selectedItem = tabBar.items![2] as? UITabBarItem 
    } 
} 

我这样做...但整个应用程序崩溃(不知道为什么)。我的标签栏中有5个项目。如何更改iOS Swift中的默认标签栏项目?

回答

1

使用self.tabBarController.selectedIndex = 2

,而不是self.tabBar

+0

我已经试过这一点,但什么都没有发生。 – TIMEX

+0

tabbar是否配置正确?你确定.. –

+0

这是你的tabbarcontroller? –

相关问题