Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i set the badge in tab bar in objective-c?

I want to put the notification in the tab bar of the app to show the number of item selected for the shopping list. Is there any way to add the notification in the tab bar of app.

like image 585
uttam Avatar asked Feb 16 '10 05:02

uttam


2 Answers

You mean the badge? Do something like (where self is a UIViewController):

[[self tabBarItem] setBadgeValue:@"42"];
like image 190
Dave DeLong Avatar answered Nov 14 '22 22:11

Dave DeLong


On the storyboard you have to select your navigation view controller if you have and then open your Property window and set Badge according to your requirement.

if you want to set programmatically

1. find your tabbar Item by viewcontroller

 # badge=what you want to set.   

2.[[[[self tabBarController] tabBar] items] objectAtIndex:1] setBadgeValue:badge];

and if you want to set by storyboard please refer this image.

enter image description here

Hope this will helps. Thanks


Also if you want to use in swift. Below code will work for you

[[self tabBarItem] setBadgeValue:@"42"];

like image 4
Ram S Avatar answered Nov 14 '22 22:11

Ram S