簡體   English   中英

如何在iOS Swift中更改默認的標簽欄項?

[英]How do I change the default tab bar item in iOS Swift?

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個項目。

使用self.tabBarController.selectedIndex = 2

代替self.tabBar

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM