views:

44

answers:

2

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!

+2  A: 

UILabel, unless set up otherwise, only displays a single line of text.

Change the numberOfLines property if you want more.

Steve Madsen
A: 

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.

Andrew