我正在设置视图时,像在表中的第一个视图一样滑动table view单元格,它需要坚持作为第二个视图,并更改其颜色。
在Swift 4和iOS中有可能吗?
最佳答案
在视图控制器中获得刷卡手势后,执行下一步:
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是一个显示的对象数组(包含数据、颜色等)
您可以手动更新必需的字段而不是更新
代码可能有错误,但应该清楚
关于ios - UITableView滑动操作可删除并使用自定义 View 进行编辑,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55743952/