Skip to content

Instantly share code, notes, and snippets.

@quinncnl
Last active April 9, 2020 09:08
Show Gist options
  • Save quinncnl/4bcd363faae942aea9d32622793b8de4 to your computer and use it in GitHub Desktop.
Save quinncnl/4bcd363faae942aea9d32622793b8de4 to your computer and use it in GitHub Desktop.
How to detect when a UIScrollView has finished scrolling
// http://stackoverflow.com/questions/993280/how-to-detect-when-a-uiscrollview-has-finished-scrolling
func scrollViewDidScroll(scrollView: UIScrollView) {
performSelector(#selector(UIScrollViewDelegate.scrollViewDidEndScrollingAnimation(_:)), withObject: nil, afterDelay: 0.3)
}
func scrollViewDidEndScrollingAnimation(scrollView: UIScrollView) {
print("scrollViewDidEndDecelerating")
NSObject.cancelPreviousPerformRequestsWithTarget(self)
refreshArtworks()
}
func refreshArtworks() {
if let userlikeArray = userlikeArray {
for indexPath in tableView.indexPathsForVisibleRows! {
if let cell = self.tableView.cellForRowAtIndexPath(indexPath) as? LikesTableViewCell {
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment