开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜