0

On my storyboard, I have one main UiTabBarController, which is then having 5 child storyboard ids. Each of the storyboard id is having its child view controllers and it expands.

My question is, when I tried to set badge value at my main UiTabBarController using the code similar like this tabBarController?.tabBar.items![0].badgeValue = "1", it won't work.

However, when I tried connecting my main UiTabBarController to its child view controllers directly (not using storyboard ids), the badge is working. Any idea why this happens? As I don't want to merge all viewcontrollers under one main.storyboard because it could get messy..

  • Does tabBarController your root view controller? – biloshkurskyi.ss Dec 12 '17 at 11:05
  • Also you should check if it available: `if let tabBar = self.tabBarController { ... }` – biloshkurskyi.ss Dec 12 '17 at 11:06
  • Yes my main tabBarController is my root view controller, and I've set it as the initial view controller on storyboard as well.. personally I've [tried this link](https://stackoverflow.com/a/41713963/9088278) and it works well if I am not connecting to storyboard ids – Heng Zhenjing Dec 12 '17 at 11:45
  • Try to get your `tabBar` from `appDelegate` dirrectly: `UIApplication.shared.keyWindow?.rootViewController as! UiTabBarController` and setup budge to it. – biloshkurskyi.ss Dec 12 '17 at 11:51

0 Answers0