我的UIView中有一些基于这样的计时器的代码:
//Start timer
self.timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true, block: {
timer in
if self.timerCount > 0 {
let minutes = Int(self.timerCount/60)
let seconds = Int(self.timerCount%60)
UIView.performWithoutAnimation {
self.proxyView!.confirmButton.setTitle(CHRText.apptConfirmButton + " (" + String(describing:minutes) + ":" + String(describing: seconds) + ")", for: UIControlState.normal)
}
self.timerCount -= 1
}
else{
self.timer!.invalidate()
}
})
除了一个问题,代码工作正常。当我在视图中滚动UIScrollView时,按钮标题不会更新。完成滚动后,标题的所有更新都会快速连续发生,就像排队一样。如何在滚动时不停止更新此文本?