Changing UILabel over time?
I have a simple UILabel on that I want to change the text of e开发者_C百科very 10 seconds. What is the best way of doing this, which let's the rest of the interface remain active?
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10.0f target:self selector:@selector(updateLabel:) userInfo:nil repeats:YES];
self.repeatingTimer = timer;
...
- (void) updateLabel:(id)sender {
myLabel.text = newStringValue;
}
...
[repeatingTimer invalidate];
self.repeatingTimer = nil; // stops timer
All you need is to start an NSTimer and update the label.text each time.
精彩评论