Drag a cell between different types of collection

I have several types of viewing on one screen

In Collection One, I have a normal cell, such as Square. In collectionView two, I have a group cell, for example, the same cell, but several are surrounded by the group border

I need to enable drag and drop between one collection to another.

POC Snap Shot Attached here

I am using swift 3.0.

+6
source share
2 answers

Drag from the View2 collection:

  • Create an independent and draggable instance of the cell with the same data and place it above the cell to drag
  • In Collectionview2 set cell.isHidden = yes . Thus, the cell is not visible, but its empty space remains.
  • When the draggable cell is draggable from its original position, remove the original cell from the CollectionView animated set.

Drag into collectionView1:

When the drag cell is above the View1 collection and discarded:

  • insert (animate) the cell to the target position in the View1 collection and set it hidden.
  • move the draggable cell over the inserted (but hidden) cell
  • set the target cell to isHidden = false
  • remove cell with drag and drop from supervisor
+2
source

Source: https://habr.com/ru/post/1014461/


All Articles