Objective C unable to update UILabel more than once
I have a method which I created that appends some new text to a UILabel. I've tried two ways of doing this (one is commented out) 开发者_开发百科but both of them only update the label the first time. Any more calls to this method do not update the label.
- (void) updateLog: (NSString*) text
{
/*
NSMutableString *newText = [logLabel.text mutableCopy];
[newText appendString: text];
logLabel.text = newText;
*/
logLabel.text = [logLabel.text stringByAppendingFormat:@"%@", text];
}
I am calling the method like this (the method is in the viewController):
[viewController updateLog: @"\nStarting...\n"]; // Works
[viewController updateLog: @"Test\n"]; // Does not work
I have searched everywhere for an answer, what am I missing? Thanks!
UILabel
, unless set up otherwise, only displays a single line of text.
Change the numberOfLines
property if you want more.
I actually figured this out. Turns out the string WAS being successfully updated, but the label size was too small, so the text was hidden.
精彩评论