0
我正在使用下面的代码在2秒内更新一个用户界面50次,这给出了0.04个时间间隔。然而,updateLabels方法只有5次或6次调用,有时远不是50次。这是因为我阻止了任何东西的主线?你们知道如何使它工作吗?NSTimer不安排足够多的选择器的时间
self.timer = [NSTimer timerWithTimeInterval:0.04
target:self
selector:@selector(updateLabels)
userInfo:nil
repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
您应该阅读'NSTimer'的文档。关于重复计时器是如何工作的,有一个全面的讨论。 – rmaddy
你怎么知道updateLabels被称为5-6次?是否有可能在该方法内运行持续40ms以上的代码? – icould