Swift表视图,在SwipeAction之后重新加载Rows,无法在同一行上再次滑动



我有一个带有swipeActions的tableView,并且这些动作调用CCD_ 1来更新我的表。

我注意到我不能在操作后再次滑动刚刚更新的行。

问题是这个单元格显示了SwipeActions面板的keep统计信息。我认为一个简单的方法,"扫回"这个单元格将解决我的问题,但我没有找到任何。

(我不想重新加载整张表查看(

func tableView(_ tableView: UITableView, 
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let removeAction = UIContextualAction(style: .normal, title: nil, handler: { _, _, _ in
self.tableView.reloadRows(at: [indexPath], with: .automatic)
//            self.items.remove(at: indexPath.row)
//            self.tableView.deleteRows(at: [indexPath], with: .automatic)
})
removeAction.image = UIImage(named: "ic_garbage")!.scaleImageToFitSize(size: CGSize(width: 32.0, height: 32.0))
removeAction.backgroundColor = UIColor.lightGray
let actionModify = UIContextualAction(style: .normal, title: nil, handler: { _, _, _ in
self.tableView.reloadRows(at: [indexPath], with: .automatic)
//            self.changeQty(indexPath)
})
actionModify.image = UIImage(named: "ic_exchange")!.scaleImageToFitSize(size: CGSize(width: 32.0, height: 32.0))
actionModify.backgroundColor = UIColor.orange
let toReturn = UISwipeActionsConfiguration(actions: [removeAction, actionModify])
toReturn.performsFirstActionWithFullSwipe = false
return toReturn
}

您需要调用完成处理程序。你的行为应该这样定义。。。

let action = UIContextualAction(style: .normal, title: "Hello") { (action, view, completion) in
self.doSomething()
completion(true)
}

最新更新