0

enter image description here

Hello all, Above is the snapshot of my application which gets push notification from my server. There are 3 notification for now and i have put that in my right menu bar inside a UITable view. Everything is working fine but i want to ask how do i put a badge to my right menu bar telling the user that he has received 3 notification and so on if the notification are more. Any suggestion or links that i could follow. Thanks in advance

Abstract
  • 561
  • 1
  • 8
  • 29

2 Answers2

0

OK so I suspect the right part is a UINavigationController with a logo in the middle view and you want to display the number of messages received where the right button usually goes. So the first thing I notice is that if the logo is centred then the right button where that number should go just falls off.

So try it just to be sure with the leftBarButtonItem. This is the approach:

  • Count the amount of messages
  • If they're more than 0 display a orange circle or whatever you want to use as the background for the leftBarButtonItem
  • If not remove the background just to be sure
  • Put the count as the button text unless it's zero

This will leave you with a useless button but that's not too bad in this case.

https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UINavigationItem_Class/index.html

Lucas van Dongen
  • 9,328
  • 7
  • 39
  • 60
  • You should abandon using a UINavigationController as it's a pig to customize. Probably you can abuse it in a way that lets you do what you want but using a UIView as a header instead for this simple screen will make your code much more elegant. – Lucas van Dongen Oct 28 '14 at 10:48