ios - UITableView 滑动操作删除和编辑自定义视图
解决方案
在视图控制器中获得滑动手势后,您将执行以下操作:
func didSwipe(_ cell: UITableViewCell) {
let indexPath = tableView.indexPath(for: cell)
if indexPath.row + 1 < myViewModels.count - 1 {
// Store the info from the next view model to the current one
myViewModels[indexPath.row].update(with: myViewModels[indexPath.row + 1])
tableView.reloadItems(at: [indexPath])
}
}
myViewModels 是您正在显示的对象数组(包含数据、颜色等),您可以手动更新必要的字段而不是更新
代码可能有错误,但思路应该很清楚
推荐阅读
- wordpress - Fortumo Web SDK 处理
- python - python中的子集问题 - 修复总和到目标的加数
- python - SQLAlchemy `.fetchmany()` 与 `.limit()`
- mysql - 无法更改 Laravel 表列类型
- c# - ItemsControl 内的 WPF C# Checkbox IsChecked 绑定
- azure-functions - 天蓝色函数host.json设置不持久
- java - 如何拆分字符串并保存我拆分的 2 个字符?
- powershell - 将参数作为数组传递给 PowerShell 函数
- python - Django 中的单例对象行为
- python - 仅通过附加和使用范围函数来删除索引