0

Code snippet:

self.tabBarController?.tabBar.items?[2].badgeValue = "999"

The code above works, but my tab bar badge updates only when I scroll (interact with) the view. Any thoughts?

The badgeValue is updated whenever I add or remove an item from a shopping bag. This function is in the Bag class:

func adicionarProduto(idProduto : Int){ 
    produtos.append(idProduto) self.tabBarController?.tabBar.items?[2].badgeValue = String(sacola.produtos.count) 
}

Thanks!

valosip
  • 3,167
  • 1
  • 14
  • 26
  • 1
    Define in your question where or/and when exactly you try to update the tab bar batch count please. – devshok Mar 03 '20 at 18:41
  • Where in the code are you setting the badgeValue? – valosip Mar 03 '20 at 18:43
  • The badgeValue is updated whenever I add or remove an item from a shopping bag. This function is in the Bag class: `func adicionarProduto(idProduto : Int){ produtos.append(idProduto) self.tabBarController?.tabBar.items?[2].badgeValue = String(sacola.produtos.count) }` – Leonardo Martelotte Mar 03 '20 at 18:55

0 Answers0