ios - NSTimer与UITableView
<p>我有带有“开始”按钮的<code>UIView</code>,带有我的<code>UILabel</code>时间的<code>NSTimer</code>和带有时间记录的<code>UITableView</code>。<br><br>问题是当我滚动<code>tableview</code>-<code>NSTimer</code>冻结时,为什么我可以使它们异步工作?<br><br>我的代码:<br><pre><code>- (IBAction)startTimer {
_startButton.hidden = YES;
_stopButton.hidden = NO;
isRun = YES;
UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid;
UIApplication *app = ;
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
;
}];
myTimer = [NSTimer scheduledTimerWithTimeInterval:0.01f
target:self
selector:@selector(tick)
userInfo:nil
repeats:YES];
}
- (void)tick {
_timeSot++;
sot++;
/*some code*/
myTime = ;
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p>将<code>myTimer</code>添加到<code>NSRunLoopCommonModes</code>:<br><pre><code>myTimer = [NSTimer scheduledTimerWithTimeInterval:0.01f
target:self
selector:@selector(tick)
userInfo:nil
repeats:YES];
[ addTimer:myTimer forMode:NSRunLoopCommonModes];
</code></pre></p>
<p style="font-size: 20px;">关于ios - NSTimer与UITableView,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/24624497/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/24624497/
</a>
</p>
页:
[1]