iphone - iOS : Timer doesn't run when we are scrolling any view

标签 iphone animation swift3 timer ios10

我使用计时器每 0.025 秒更新一次进度条,但是当我滚动我的 collectionView 或 tableView 或任何 ScrollView 时,我的计时器不会运行,导致我的进度条卡住了一会儿,直到我结束滚动操作。我已使用 CADisplayLink 作为计时器,但它仍然具有相同的行为。解决这个问题的最佳方法是什么?我已经看到 iTunes 预览歌曲中的循环进度播放按钮即使在 ScrollView 时仍在更新,所以我确信这个问题是可以解决的。

最佳答案

我已经弄清楚我错过了什么。

只需在安排计时器后添加此代码,当您滚动 tableView 或 collectionView 时它仍然有效

RunLoop.current.add(self.timer!, forMode: RunLoopMode.commonModes)

关于iphone - iOS : Timer doesn't run when we are scrolling any view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44963574/

相关文章:

iphone - 如何使用 NSPredicate 检索 NSArray 的索引?

ios - iOS检查iTunes帐户是否已登录

iphone - 如何将 gcc 4.2 与 Xcode 4.2 一起使用

javascript - 为什么我的动画会做我不期望的事情?

ios - Swift 为现有用户默认值增加值(value)

iphone - UIDEVICE方向

html - 悬停完成后,CSS 会淡出

javascript - 如何在 jquery 动画函数中传递原始显示属性?

ios - swift 3 layoutIfneeded 无法正常工作

Swift编译错误: "cannot load underlying module for ' CoreGraphics '"with ` import Foundation`