有没有办法检查我的 tableview 是否刚刚完成滚动?table.isDragging
和 table.isDecelerating
是我能找到的仅有的两种方法.我不确定当 tableview 完成滚动时如何预测或收到通知.
Is there a way to check if my tableview just finished scrolling? table.isDragging
and table.isDecelerating
are the only two methods that I can find. I am not sure how I can either anticipate or get notified when the tableview finishes scrolling.
我可以以某种方式使用计时器来检查 tableView 是否正在滚动吗?
Can I somehow use timers to check every second if the tableView is scrolling or not?
你将实现 UIScrollViewDelegate
协议方法如下:
You would implement UIScrollViewDelegate
protocol method as follows:
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (!decelerate) {
[self scrollingFinish];
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self scrollingFinish];
}
- (void)scrollingFinish {
//enter code here
}
斯威夫特版本
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if decelerate {
scrollingFinished()
}
}
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
scrollingFinished()
}
func scrollingFinished() {
print("scrolling finished...")
}
对于上述委托方法当用户的手指在拖动内容后触摸起来时,滚动视图会发送此消息.UIScrollView 的 decelerating 属性控制减速.
当视图减速停止时,参数decelerate
将为NO
.
For the above delegate method The scroll view sends this message when the user’s finger touches up after dragging content. The decelerating property of UIScrollView controls deceleration.
When the view decelerated to stop, the parameter decelerate
will be NO
.
第二个用于缓慢滚动,甚至当你的手指触摸时滚动停止,正如 Apple Documents 所说,当滚动运动停止时
.
Second one used for scrolling slowly, even scrolling stop when your finger touch up, as Apple Documents said, when the scrolling movement comes to a halt
.
这篇关于如何检查 UITableView 何时完成滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!