Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingnight/a27bc709b6e285a724bb9a8d00c3d5bd to your computer and use it in GitHub Desktop.
Save kingnight/a27bc709b6e285a724bb9a8d00c3d5bd to your computer and use it in GitHub Desktop.
Used when loading more data into UITableView for a smooth "infinite scroll" feel
// I dont want my table jumping/animation when appending new rows
// for an infinite scroll feel
//
// Some of this might not be needed but it works
//
// TODO: Possibly garbage
extension UITableView {
func reloadDataSmoothly() {
UIView.setAnimationsEnabled(false)
CATransaction.begin()
CATransaction.setCompletionBlock { () -> Void in
UIView.setAnimationsEnabled(true)
}
reloadData()
beginUpdates()
endUpdates()
CATransaction.commit()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment