How to add a badge to the system generated “More” UITabBarItem

不想你离开。 提交于 2019-12-30 19:49:54

问题


My app has 6 menu items, so the OS shows the first 4, then shows a "More" item that links to a screen where the user can select the other two.

My problem is that I want to show a badge on the More item so that the user knows that one of the menu items that is hidden needs their attention. (It's clear to our users which hidden item the badge represents since one of the hidden items is Settings and the other is current Uploads)

I don't know how to access the "More" item since the "items" array on UITabBar only contains the 6 actual UITabBarItems that I've created; it doesn't include the system generated "More" item. I've tried setting the badge on one of the hidden UITabBarItems, but no badge is ever displayed.

I didn't find much on Google, which makes me wonder if I'm going about this completely wrong. The iTunes app does the same thing when you download items. They display a More item and attach a badge to it, so I figured I was in good company, but I'll be damned if I see how they did that. (Unless they manually created a UITabBarSystemItemMore item and manually handled displaying the other menu items. Ugh.)


回答1:


Actually you can modify the tab bar item of the "more navigation controller" of your tab bar controller. If your tab bar controller is "tabBarController", you can do it this way.

UITabBarItem *item = [tabBarController moreNavigationController].tabBarItem; 
item.badgeValue = @"100";


来源:https://stackoverflow.com/questions/2387401/how-to-add-a-badge-to-the-system-generated-more-uitabbaritem

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