拖放tableView单元格

时间:2019-08-30 09:50:19

标签: uitableview swift4.2

我已经在tableView中实现了拖放功能。问题是当我拖放单元格时,放置位置的索引与拾取位置索引相同。如何保持放置位置索引不变。

例如:我有两个单元格cell-0和cell-1都具有UILable。将cell-1拖到第0个索引后,我的表显示: 细胞1 cell-0

如果我修改了cell-0标签的任何更改,它也会更改cell-1的标签。

拖放后保持单元格索引不变的任何解决方案。否则将不胜感激。

func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {

    let movedObject = self.tableStoryArray[sourceIndexPath.row]
    tableStoryArray.remove(at: sourceIndexPath.row)
    tableStoryArray.insert(movedObject, at: destinationIndexPath.row)
    debugPrint("\(sourceIndexPath.row) => \(destinationIndexPath.row)")

}

0 个答案:

没有答案