2015-09-01 90 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? –

相關問題