我有一个带有imageView的scrollView.这scrollView是superView的一个子视图,而imageView是一个子视图scrollView.我还有一个标签(在超级视图级别),每隔毫秒从NSTimer接收其text属性的更新值.
问题是:在滚动期间,标签停止显示更新.滚动结束时,标签上的更新将重新开始.更新重启时,它们是正确的; 这意味着label.text值按预期更新,但在滚动时,更新显示在某处覆盖. 无论滚动与否,我都希望在标签上显示更新.
以下是标签更新的实现方式:
- (void)startElapsedTimeTimer {
[self setStartTime:CFAbsoluteTimeGetCurrent()];
NSTimer *elapsedTimeTimer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(updateElapsedTimeLabel) repeats:YES];
}
- (void)updateElapsedTimeLabel {
CFTimeInterval currentTime = CFAbsoluteTimeGetCurrent();
float theTime = currentTime - startTime;
elapsedTimeLabel.text = [NSString stringWithFormat:@"%1.2f sec.", theTime];
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.