徽章没有显示价值

时间:2014-06-24 10:05:06

标签: ios uibutton nsstring nsinteger

我有一个barButton徽章。 我想在其中显示一个整数。

@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;

在NSLog中,我得到了正确的值。

我还尝试了其他一些方法:

NSString *strValue = [NSString stringWithFormat:@"%d", section];
NSString *strValue = [NSString stringWithFormat:@"%i", section];
barButton.badgeValue = [NSString stringWithFormat:@"%d", section]; 

它有什么原因吗?


修改

    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];

0 个答案:

没有答案