[英]UITableView swipe action delete and edit with custom view
Once you are getting the swipe gesture in view controller you do the next: 在View Controller中获得滑动手势后,请执行以下操作:
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 is an array of object(contains data, colors, etc) that you are displaying Instead of update you can manually update necessary fields myViewModels是要显示的对象数组(包含数据,颜色等),而不是更新,您可以手动更新必要的字段
The code may have an errors but the idea should be clear 代码可能有错误,但是思路应该清晰
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.