Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a tabBarController set up in the AppDelegate and have a few UIViewControllers with Nav Controllers. In one of the TabBar items, after I have pushed a few UIViews I want to update the badgeValue item of a different TabBar item.

Whats the best way to do this? The only way I can really think is a NSNotification and a singleton storage for the value, but it seems a lot of work for something simple, that and I have no idea about NSNotifications.

I had a wild guess at something like super.tabBarController.otherView.tabBarItem.badgeValue = @"1" (as I set which tab is selected in a similar way) but I'm not surprised this doesn't work.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
397 views
Welcome To Ask or Share your Answers For Others

1 Answer

Thanks to alku83 who pointed me in the right direction the code is:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...