There is a UIScrollViewDelegate method that you can use to detect (or, better say, βpredictβ) when the scrolling is really complete:
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
of UIScrollViewDelegate , which can be used to detect (or, better say, "predict") when scrolling is truly complete.
In my case, I used it with horizontal scrolling as follows (in Swift 3 ):
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { perform(#selector(self.actionOnFinishedScrolling), with: nil, afterDelay: Double(velocity.x)) } func actionOnFinishedScrolling() { print("scrolling is finished")
source share