【发布时间】:2011-09-14 06:51:02
【问题描述】:
我有一个关于 UILabel 的问题。我什至不确定这是否是正确的方法,但我正在尝试更新 UILabel 以显示从 0 到 24 的两个数字,然后循环回零并再次显示数字序列。问题是,它需要每 1/24 秒更新一次 UILabel。这是我到目前为止的代码......
- (void)viewDidLoad {
fpsTimer = [NSTimer scheduledTimerWithTimeInterval: .01 target: self selector: @selector(updateFpsDisplay) userInfo: nil repeats: YES];
}
- (void)updateFpsDisplay {
for (int i=0; i<100; i++) {
NSLog(@"%d", i%24);
[timecodeFrameLabel setText:[NSString stringWithFormat:@"0%d", i%24]];
}
}
这段代码在运行时成功地在控制台中循环打印出数字1-24,但是名为“timecodeFrameLabel”的UILabel只显示03并且没有改变。
有什么建议吗?
【问题讨论】:
-
NSTextField waits until the end of a loop to update 的可能重复项。相同的潜在问题适用,即使该问题涉及 NSTextField 并且这是 UILabel。
标签: objective-c uilabel nstimer