问题描述
我附上了一张图片。
这是 iPhone 的默认提醒应用。 像这样,当拖动单元格重叠时,我想制作灰色背景。
这是我尝试过的:;但它在模拟器中看起来很丑。
var beforetouch: IndexPath?
func tableView(_ tableView: UITableView,targetIndexPathForMoveFromrowAt sourceIndexPath: IndexPath,toProposedindexPath proposedDestinationIndexPath: IndexPath) -> IndexPath {
if let cell = tableView.cellForRow(at: proposedDestinationIndexPath) {
if (self.beforetouch != sourceIndexPath)
&& (sourceIndexPath != proposedDestinationIndexPath) {
if self.beforetouch == nil {
cell.setSelected(true,animated: false)
} else {
cell.setSelected(true,animated: false)
tableView.cellForRow(at: beforetouch!)?.setSelected(false,animated: false)
}
}
self.beforetouch = proposedDestinationIndexPath
}
return proposedDestinationIndexPath
}
func tableView(_:,targetIndexPathForMoveFromrowAt:,toProposedindexPath:) -> IndexPath
好像每次拖动时都会执行,可以通过参数的IndexPath来追踪单元格。
另外,我认为会出现性能问题,因为'cell.setSelected()' 用于在拖动时连续调用的tableView 函数中。我也遇到了必须把前一个单元格的indexPath存储在类的storage属性中的问题,所以我正在寻找另一种方式。
有人可以帮助我如何实现它吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)