Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag and Drop cell between different Collection Views

Tags:

ios

swift

swift3

I have multiple collection views on one screen

In collectionView One i have normal cell like Square In collectionView two i have group cell e.g same cell but multiple surrounded by a border of Group

I need to Enable Drag and Drop between One Collection View to Another.

POC Snap Shot Attached here

I am using swift 3.0.

like image 538
Muhammad Faizan Khatri Avatar asked Jan 26 '17 14:01

Muhammad Faizan Khatri


People also ask

What is drag and drop collection?

The basic sequence involved in drag and drop is: Move the pointer to the object. Press, and hold down, the button on the mouse or other pointing device, to "grab" the object. "Drag" the object to the desired location by moving the pointer to this one. "Drop" the object by releasing the button.

What is swift Uicollectionview?

An object that manages an ordered collection of data items and presents them using customizable layouts.


2 Answers

You can use this one from GitHub:

https://github.com/mmick66/KDDragAndDropCollectionView

enter image description here

And here is a nice guide for it:

http://blog.karmadust.com/drag-and-drop-between-uicollectionviews/

like image 86
Andriy Savran Avatar answered Nov 09 '22 08:11

Andriy Savran


Drag from collectionView2:

  • Create an independent and drag-able instance of the cell with the same data and place it above the cell to drag
  • In Collectionview2, set the cell.isHidden = yes. This way the cell is not visible, but its empty space remains.
  • When the drag-able cell is significant dragged away from the original position, remove the original cell from the collectionView animated.

Drag to collectionView1:

When the drag-able cell is above collectionView1 and is dropped:

  • insert (animated) a cell to the target position in collectionView1 and set it hidden
  • move drag-able cell above the inserted (but hidden) cell
  • set target cell to isHidden = false
  • remove drag-able cell from superview
like image 41
shallowThought Avatar answered Nov 09 '22 06:11

shallowThought