I'm writing an app for the iPhone and I'm finding that the UILabel is not updating. A worker thread updates a string and calls a method on the view that changes the text in a UILabel subview.
I'm not seeing the new values appear in the UILabel.
Here's the code for the view, the updateDisplay method is called by the worker thread.
Anybody know why the UILabel doesn't get updated?
I attached the whole project.
Thx
I'm not seeing the new values appear in the UILabel.
Here's the code for the view, the updateDisplay method is called by the worker thread.
Anybody know why the UILabel doesn't get updated?
I attached the whole project.
Thx
Code:
#import "MyView.h"
@implementation MyView
@synthesize label;
-(id)initWithFrame:(CGRect)aRect
{
if (![super initWithFrame:aRect]) return nil;
self.backgroundColor = [UIColor whiteColor];
CGRect labelFrame = CGRectInset(aRect, 90, 90);
self.label = [[UILabel alloc] initWithFrame:labelFrame];
self.label.contentMode = UIViewContentModeRedraw;
[self addSubview: self.label];
[self bringSubviewToFront:self.label];
self.label.text = @"initial value";
return self;
}
-(void) updateDisplay:(NSString *)str
{
self.label.text = str;
[self.label setNeedsDisplay];
//[self setNeedsDisplay];
//[self.window setNeedsDisplay];
}
@end
Attachments
Last edited by a moderator: