无法在重构的故事板上设置标签栏徽章值

Unable to set Tab Bar Badge value on Refactored Storyboard

我重构了故事板,但现在无法在重构的故事板上设置徽章值。

这是主故事板,MessageCenter 是重构的故事板。

消息中心故事板:

我正在应用委托中设置徽章值,但它不起作用:

如果让 tabBarController = self.window!.rootViewController 为? UITabBarController { tabBarController.tabBar.items!2.badgeValue = "3" }

有什么想法吗?

如果让 tabBarController = self.window?.rootViewController as? UITabBarController { tabBarController.viewControllers?[2].tabBarItem.badgeValue = "3" }

在您的 TabBarCustomViewController 中尝试使用此代码:

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