在 UIViewController 的 UITabBarItem 中设置徽章值 [英] Setting badge value in UITabBarItem in UIViewController

查看:27
本文介绍了在 UIViewController 的 UITabBarItem 中设置徽章值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 UITabBarController 添加到窗口,并将 UITabBarController 的 viewControllers 属性设置为 ViewControllers 数组.如果我在 viewController 中设置徽章值,那么它工作正常.self.tabBarItem.badgeValue = @"3";

I am adding UITabBarController to the window, and setting the viewControllers property of the UITabBarController to the array of ViewControllers. If i am setting the badge value inside the viewController then its working fine. self.tabBarItem.badgeValue = @"3";

但是如果我将 UITabBarController 的 viewControllers 属性设置为导航控制器数组,该数组将视图控制器作为 rootviewcontroller,那么它不会设置徽章值.

But if i am setting the viewControllers property of the UITabBarController to the array of navigation controllers which is having view controller as the rootviewcontroller, then its not setting the badge value.

有什么建议吗??

谢谢

推荐答案

是的,我得到了答案.

[[self navigationController] tabBarItem].badgeValue = @"3";

这篇关于在 UIViewController 的 UITabBarItem 中设置徽章值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆