首页 > 解决方案 > Swift/Xcode 标签栏徽章刷新

问题描述

代码片段:

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

上面的代码有效,但我的标签栏徽章仅在我滚动(与)视图时更新。有什么想法吗?

每当我从购物袋中添加或删除商品时,都会更新 badgeValue。这个函数在 Bag 类中:

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

谢谢!

标签: swiftxcodetabbarbadge

解决方案


推荐阅读