奇怪的问题,我试图设置titleLabel.text,但它不会从默认标题文本更改。我已经在调试器中逐步完成了它,并检查了正确为新值的taskTitle值,但titleButton.titleLabel.text属性似乎未采用值赋值。无法更改UILabel.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)];
}
'titleButton'如何?可能是零? – paulmelnikow 2013-03-11 23:49:15