【发布时间】:2020-03-26 04:08:06
【问题描述】:
当我尝试删除 UITableview 中的一行时,列表向上移动 2 行,动画行为也很奇怪,因为您可以看到 2 个“Water:11”单元格出现(向下移动)......这是怎么回事?我在 Xcode 9.4.1 版本中使用 swift,这是我的删除代码:
override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let deleteAction = UITableViewRowAction(style: .destructive, title: "DELETE") { (action, actionIndexPath) in
tableView.beginUpdates()
tableView.deleteRows(at: [indexPath], with: .automatic)
Results.remove(at: indexPath.row)
tableView.endUpdates()
}
return [deleteAction]
}
【问题讨论】:
-
是的,它解决了我的问题!非常感谢!
标签: ios swift xcode uitableview