2017-02-15 51 views
0

我重構了我的故事板,現在我無法在重構故事板上設置徽章值。無法在重構故事板上設置標籤欄徽章值

這是主要的故事板和消息中心是重構的故事板。

enter image description here

信息中心故事板:

enter image description here

我設置的應用程序委託,這是不工作的徽章值:

如果讓tabBarController =自我。窗口!.rootViewController爲? UITabBarController {} {tabBarController.tabBar.items! 2 .badgeValue =「3」 }

任何想法?

+0

只有一個在重構標籤欄控制器元件。 ... – jarryd

回答

1

嘗試使用這個代碼在TabBarCustomViewController:

DispatchQueue.main.async(execute: { 
       self.tabBar.items?[3].badgeValue = "3" 
}) 
+0

工作!你能告訴我爲什麼嗎? – Jonesie

+0

也許你不在主線程中,如果你想改變與UI相關的東西,你需要在主線程中 – DiegoQ

0

if let tabBarController = self.window?.rootViewController as?的UITabBarController {? tabBarController.viewControllers [2] = .tabBarItem.badgeValue 「3」 }

+0

不幸的是,這沒有奏效。謝謝您的好意。我很欣賞這種迴應。 – Jonesie

+0

對不起,它沒有工作,我發誓它在我的機器:) –