我在tableview中安装了一个刷卡删除功能。没什么特别的。但是,执行时,即使已删除的单元格已经消失,红色删除按钮(行动作)也会在向下缩回到右下方的单元格时重叠。
在editActionsForRowAt函数中,我首先从数组中删除值,然后从Firebase中的引用中删除。这是代码:
func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
let delete = UITableViewRowAction(style: .normal, title: "Verwijder") { action, index in
tableView.beginUpdates()
let item = self.joinedArrayFiltered[editActionsForRowAt.section][editActionsForRowAt.row]
let indexPath: IndexPath = IndexPath(row: editActionsForRowAt.row, section: editActionsForRowAt.section)
self.joinedArrayFiltered[editActionsForRowAt.section].remove(at: editActionsForRowAt.row)
self.ref.child("productsObserver").child(item.productId).child("wishlistUsers").child(self.userID).removeValue()
tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.bottom)
tableView.endUpdates()
}
delete.backgroundColor = .red
return [delete]
}
为帮助查看问题,请参阅下面附带的GIF。
任何建议都会有所帮助,谢谢。