【问题标题】:UITableView's deleting animation does not work properlyUITableView 删除动画无法正常工作
【发布时间】: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]
}

a GIF that shows what's going on

【问题讨论】:

  • 是的,它解决了我的问题!非常感谢!

标签: ios swift xcode uitableview


【解决方案1】:

当 tableview 没有正确获得行高时,就会出现这种问题。要解决这个问题,您只需要给出估计的行高。谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    • 2011-06-29
    • 2021-06-11
    • 1970-01-01
    • 2012-03-03
    相关资源
    最近更新 更多