I have a barButton badge. I want to display an integer in it.
@property (nonatomic) int section;
@synthesize section;
-(void)sendBadgeIntBack:(int)section
{
self.section = section;
NSLog(@"The numbers of sections in tableView are: %i", self.section);
}
NSString *strValue = [@(section) stringValue];
BBBadgeBarButtonItem *barButton = [[BBBadgeBarButtonItem alloc] initWithCustomUIButton:customButton];
barButton.badgeValue = strValue;
In the NSLog I get a correct value.
I've also tried some other ways:
NSString *strValue = [NSString stringWithFormat:@"%d", section];
NSString *strValue = [NSString stringWithFormat:@"%i", section];
barButton.badgeValue = [NSString stringWithFormat:@"%d", section];
Is there a reason why it doesn't work?
Edit:
UIButton *customButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
[customButton addTarget:self action:@selector(barButtonItemPressed:) forControlEvents:UIControlEventTouchUpInside];
[customButton setImage:[UIImage imageNamed:@"afvaldag"] forState:UIControlStateNormal];