iPhone unread counts on tabbar

时间秒杀一切 提交于 2019-12-07 01:50:25

问题


Which is the best way to implement on Cocoa Touch the unread counts on a icon on a TabBar?

I want to mimic the SMS or Mail application behavior, showing the unread message count to the user of my application, with a red dot containing a number.


回答1:


The property you're looking for is called the badge. You set it by doing something like:

self.tabBarItem.badgeValue = @"1";



回答2:


Have you looked at: setApplicationBadgeNumber?

[[UIApplication sharedApplication] setApplicationBadgeNumber:int];



回答3:


For current view I use:

self.navigationController.tabBarItem.badgeValue = @"5";


来源:https://stackoverflow.com/questions/610172/iphone-unread-counts-on-tabbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!