我想在SwipeCell执行删除操作后更新视图,它在此处崩溃了:
func swipeController(_ controller: SwipeController, didDeleteSwipeableAt indexPath: IndexPath) {
tableView?.deleteRows(at: [indexPath], with: .none)
}
崩溃信息:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 1 from section 0 which only contains 1 rows before the update'
这是我的示例代码。我知道它在框架内做了一些动画处理。是否有任何委托函数可以调用并安全更新我的表视图?请告诉我,非常感谢
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {
let delete = SwipeAction(style: .destructive, title: nil) { action, indexPath in
// want to reload tableview here
}
delete.hidesWhenSelected = true
configure(action: delete, with: .trash)
return [delete]
}
func tableView(_ tableView: UITableView, didEndEditingRowAt indexPath: IndexPath?, for orientation: SwipeActionsOrientation) {
// or here
}