我试图设置 titleLabel.text 但它不会从默认标题文本更改的奇怪问题。我已经在调试器中逐步检查了它并检查了 taskTitle 值,它是正确的新值,但 titleButton.titleLabel.text 属性似乎没有进行值分配。
- (void)setChallengeTitle:(NSString *)taskTitle
{
titleButton.titleLabel.text = taskTitle;
titleButton.titleLabel.font = [UIFont fontWithName:@"Gotham Bold" size:18];
CGSize stringsize = [taskTitle sizeWithFont:[UIFont fontWithName:@"Gotham Bold" size:18]];
//I have to add a little bit since it doesn't seem to calculate the size of gotham correctly
int buttonWidth = stringsize.width + 20;
if (buttonWidth > 320)
buttonWidth = 320;
[titleButton setFrame:CGRectMake( (320 - buttonWidth)/2 ,10, buttonWidth, 40)];
}