Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 徽章不';t显示值_Ios_Uibutton_Nsstring_Nsinteger - Fatal编程技术网

Ios 徽章不';t显示值

Ios 徽章不';t显示值,ios,uibutton,nsstring,nsinteger,Ios,Uibutton,Nsstring,Nsinteger,我有一个巴布顿徽章。 我想在其中显示一个整数 @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 = [

我有一个巴布顿徽章。 我想在其中显示一个整数

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

什么是
customButton
?这可能是它失败的原因吗?此外,BBBadgeBarbuttonite似乎是一个自定义类。来源是什么?自定义按钮是UIButton。请参阅更新。第二,来源是这里:如果您登录
badgeButton.badgeValue
,您会得到什么?何时设置
badgeButton
?当我记录badgeButton.badgeValue时,我得到0。我在ViewDidLoad中设置了badgeButton。在尝试将其转换为
NSString
之前,请尝试记录
部分。我认为您的架构有问题。