【发布时间】:2018-10-13 20:48:18
【问题描述】:
我正在尝试使用动画从 tableview 中删除行,但是在大多数情况下它会卡住。 15 次尝试中的 1 次将导致播放此动画。这是我的删除操作的样子:
func contextualDeleteAction(forRowAtIndexPath indexPath: IndexPath) -> UIContextualAction {
let action = UIContextualAction(style: .destructive,
title: "Delete") { (contextAction: UIContextualAction, sourceView: UIView, completionHandler: (Bool) -> Void) in
Model().context.delete(notesArray[indexPath.row])
notesArray.remove(at: indexPath.row)
self.myTableView.deleteRows(at: [indexPath], with: UITableView.RowAnimation.bottom)
Model().saveItems()
}
action.title = "Delete"
return action
}
当按下删除按钮时。
我也尝试过使用 tableView.beginUpdate() 和 tableView.endUpdate() 但没有得到不同的结果。
【问题讨论】:
标签: swift uitableview uikit