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.
Can I somehow use timers to check every second if the tableView is scrolling or not?
UITableView is a subclass of UIScrollView that allows users to scroll the table vertically (the closely-related UICollectionView class allows for horizontal scrolling and complex two-dimensional layouts).
You can add a UITableView to a UIScrollView and have it scroll horizontally.
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
}
Swift version
public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if decelerate {
scrollingFinished()
}
}
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
scrollingFinished()
}
func scrollingFinished() {
print("scrolling finished...")
}
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
.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With