我需要实时获取表格视图的滚动位置。我目前正在做的是:
func animationOffset() {
let offset = tableView.contentOffset.y
}
这个函数连接到一个定时器
timer = NSTimer.scheduledTimerWithTimeInterval(0.2, target: self, selector: #selector(TimelineViewController.animationOffset), userInfo: nil, repeats: true)
如果用户将手指从屏幕上移开,则此代码可以正常工作,但如果他们不这样做并继续滚动,则偏移量将永远不会更新,我的应用程序将无法正常运行。