When I trying to deleting rows, at first it behaves pretty good. However, at the instance that content size
firstly smaller than the border
of the tableview, when deleting rows the whole table suddenly jumps 1 row up...
Here is my delete row action,
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
Results.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .automatic)
}
}
In ViewDidload
I've already implement the code below
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
The animation just when wrong only when the content's height first become smaller to the border... After that the animation also ran properly...
and here's the GIF shows what happening... is that a bug in iOS 11?
OK finally I got an solution, and it looks good. I add the code below to the delete action:
if(tableView.contentSize.height<=tableView.bounds.height+100.0 && tableView.contentSize.height>tableView.bounds.height) {
tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: true)
}
// The 100.0f is the cell height.
The 100.0f is the cell's height. So when the content's height firstly smaller than the tableView's border, the tableview scrolls to the very top, and the glitch animation is covered by the scrolling animation.