iOS 11 UITableView delete rows animation bug

前端 未结 5 1229
情话喂你
情话喂你 2020-12-05 10:20

video of the tableview animation bug

I have a table view which expands/collapse its cells.

As of iOS 11, the tableView starts to behave strangely on insertio

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 11:07

    In iOS 11.2, I had a bad animation after deleting a row using the standard row actions. I was only able to improve the situation by wrapping the row delete and row action dismissal in a CATransaction.

    I dismiss the row actions first and wait for that animation to complete before deleting the row from the table view.

    It at least doesn't jump around the table views content offset anymore, but is a lengthy two step animation. I'm still looking for a better solution.

            CATransaction.begin()
            CATransaction.setCompletionBlock({
                self.tableView.beginUpdates()
                self.myViewModel?.items?.remove(at: indexPath.row)
                self.tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.top)
                self.tableView.endUpdates()
            })
            self.tableView.setEditing(false, animated: true)
            CATransaction.commit()
    

提交回复
热议问题