Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 70

Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
05/15/13 11:06 AM (12 years ago)

Developer help again!!

I'm after a bit of help if possible please. I have added a badge to uitabbarcontroller which displays the same as the way a missed call is displayed in 'phone'. What I am struggling to do is remove the badge when the tab is pressed. The method for the badge is set in viewDidLoad Any advice gratefully received :) Cheers
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
05/15/13 11:43 AM (12 years ago)
the appdelegate controls the tabbar button presses line 918. A bit more info about what your doing may result in a better answer lol
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/15/13 11:58 AM (12 years ago)
Sorry, was as clear as could make it! Added a badge to each tab in uitabbarcontroller. The code is added to the first view controller in view did load as it acts as the root view. The badges are used to inform the number of items in the view of each tab. I have tried to add code to the appdelegate already in didSelectController and set the badge to nil but it does nothing. Does this make more sense?!
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
05/15/13 12:35 PM (12 years ago)
yeah sort of how are you passing the number of screens to the badge or is this fixed. Once the tab is clicked do you ever want the badge to ever reappear. So many variables head will explode. I think you would need to set the badges up in the app delegate file, then button clicked send it to nil. When view reopens for example set the badges as the number of blah blah blah.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
05/15/13 12:37 PM (12 years ago)
I know in some push solution I saw once if I send a value of zero for the badge it clears it. Worth a try ?
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/15/13 01:10 PM (12 years ago)
@Kitts Using the following in firstviewcontroller, view did load. So this is [[[[[self tabBarController] tabBar] items] objectAtIndex:0] setBadgeValue:@"25"]; [[[[[self tabBarController] tabBar] items] objectAtIndex:1] setBadgeValue:@"30"]; etc, etc So, view loads, badges appear. This is fine as its not live and doesnt need changing unless an update is submitted. They need dismissing when touched and do not need to reappear again. So, just need to dismiss them somehow! @alan, if I add zero rather than nil i will show 'zero' in the badge. Cheers
 
theMonster
Code is Art
Profile
Posts: 435
Reg: Oct 18, 2011
US
8,050
like
05/15/13 04:15 PM (12 years ago)
Usually ppl make those appear with Notifications. You might want to look into local pushes and see if that's what your going for. As for dismissing them you can do it in the viewDidLoad of the VC you want it to dismiss them. Just like in the Phone App. -tM
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
05/15/13 04:28 PM (12 years ago)
Yeah, thats usually how they are used. Its not a critical part of my app at all. Cheers.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
05/15/13 10:17 PM (12 years ago)
@Alex -- I hope you've found the answer, please post the solution when you can. We can use it for other situations. For next time, please make the subject be more specific like this: "How to clear badges on Tabbar items?" Later onwards, that will help all of us when searching for this forum post. Thanks, -- Niraj
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.