gpt4 book ai didi

iphone - 从 UIView 更新 UITabBarController 的 badgeValue 的最佳方法

转载 作者:行者123 更新时间:2023-12-03 18:25:25 25 4
gpt4 key购买 nike

我在 AppDelegate 中设置了一个 tabBarController,并有一些带有导航 Controller 的 UIViewController。在其中一个 TabBar 项目中,在推送了几个 UIView 后,我想更新另一个 TabBar 项目的 badgeValue 项目。

最好的方法是什么?我真正能想到的唯一方法是 NSNotification 和值的单例存储,但对于简单的事情来说似乎需要做很多工作,而且我对 NSNotifications 一无所知。

我对像 super.tabBarController.otherView.tabBarItem.badgeValue = @"1"这样的东西有一个疯狂的猜测(因为我设置以类似的方式选择哪个选项卡),但我并不惊讶这不起作用。

谢谢

最佳答案

感谢 alku83 为我指明了正确的方向,代码是:

[[super.tabBarController.viewControllers objectAtIndex:2] tabBarItem].badgeValue = @"1";

关于iphone - 从 UIView 更新 UITabBarController 的 badgeValue 的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2854357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com