Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a method to check the UICollectionView item drag cancellation if the item wasn't moved?

I use drag and drop to rearrange a collectionView. When I start the drag, I change the collectionView visualization. To change it back I need a method which will be executed in any case. Now if I start the drag and release the touch immediately, none of the following methods are executed:

not this:
    func collectionView(_ collectionView: UICollectionView,  dragSessionDidEnd session: UIDragSession)

not this:
    func collectionView(_ collectionView: UICollectionView, dropSessionDidEnd session: UIDropSession)

not this:
    func collectionView(_ collectionView: UICollectionView, performDropWith coordinator: UICollectionViewDropCoordinator)

Thank you.

like image 792
Alexey Chekanov Avatar asked Apr 05 '18 21:04

Alexey Chekanov


1 Answers

From the WWDC "Introducing Drag and Drop" video it seems that the right place to handle the lift and its cancellation is the dragInteraction(_:willAnimateLiftWith:session:) method.

enter image description here

like image 170
Alexey Chekanov Avatar answered Nov 07 '22 00:11

Alexey Chekanov