Guest User

Untitled

a guest
Feb 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongGesture(gesture:)))
  2. uploadDocCollectionView.addGestureRecognizer(longPressGesture)
  3. @objc func handleLongGesture(gesture: UILongPressGestureRecognizer) {
  4.  
  5. switch(gesture.state) {
  6.  
  7. case UIGestureRecognizerState.began:
  8. guard let selectedIndexPath = self.uploadDocCollectionView.indexPathForItem(at: gesture.location(in: self.uploadDocCollectionView)) else {
  9. break
  10.  
  11. }
  12. uploadDocCollectionView.beginInteractiveMovementForItem(at: selectedIndexPath)
  13. case UIGestureRecognizerState.changed:
  14. uploadDocCollectionView.updateInteractiveMovementTargetPosition(gesture.location(in: gesture.view!))
  15. case UIGestureRecognizerState.ended:
  16. uploadDocCollectionView.endInteractiveMovement()
  17. default:
  18. uploadDocCollectionView.cancelInteractiveMovement()
  19.  
  20.  
  21. }
  22. }
  23.  
  24. func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
  25. print("Starting Index: (sourceIndexPath.item)")
  26. print("Ending Index: (destinationIndexPath.item)")
  27. }
Add Comment
Please, Sign In to add comment