Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongGesture(gesture:)))
- uploadDocCollectionView.addGestureRecognizer(longPressGesture)
- @objc func handleLongGesture(gesture: UILongPressGestureRecognizer) {
- switch(gesture.state) {
- case UIGestureRecognizerState.began:
- guard let selectedIndexPath = self.uploadDocCollectionView.indexPathForItem(at: gesture.location(in: self.uploadDocCollectionView)) else {
- break
- }
- uploadDocCollectionView.beginInteractiveMovementForItem(at: selectedIndexPath)
- case UIGestureRecognizerState.changed:
- uploadDocCollectionView.updateInteractiveMovementTargetPosition(gesture.location(in: gesture.view!))
- case UIGestureRecognizerState.ended:
- uploadDocCollectionView.endInteractiveMovement()
- default:
- uploadDocCollectionView.cancelInteractiveMovement()
- }
- }
- func collectionView(_ collectionView: UICollectionView, moveItemAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
- print("Starting Index: (sourceIndexPath.item)")
- print("Ending Index: (destinationIndexPath.item)")
- }
Add Comment
Please, Sign In to add comment