I banged my head on this issue for several hours, but every time I try something like this:
self.dataArray.append(newCellObj)
and then I do this:
self.tableView.beginUpdates() self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top) self.tableView.endUpdates()
UITableView will automatically jump to the top of the page.
Even if I try:
self.tableView.scrollEnabled = false self.tableView.beginUpdates() self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top) self.tableView.endUpdates()
UITableView will still scroll up, even if scrolling is completely disabled. What exactly makes ScrollView scroll to the top after calling insertRowsAtIndexPaths ?
The only solution I have for this problem is this:
self.tableView.reloadData()
instead of this. If I use reloadData instead, but I am losing a nice animation that I really would like to keep.
I also have self.tableView.scrollsToTop = false , and I tried using many other configurations that could disable scrolling in some way, but something that overrides this after insertRowsAtIndexPaths
source share