Forked from joshdholtz/StopJumpingTableViewOnInsertRows.swift
Created
July 11, 2018 12:31
-
-
Save daoseng33/32dc62ca2403e846d52b07428dd76ce0 to your computer and use it in GitHub Desktop.
Used when loading more data into UITableView for a smooth "infinite scroll" feel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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