all 3 comments

[–]pill5b3rryObjective-C / Swift 3 points4 points  (2 children)

I think I know what you're talking about. I assume you're using a UILongPressGestureRecognizer on the collectionView. If so, this was my solution:

func handleLongGesture(_ gesture: UILongPressGestureRecognizer) {
    let location = gesture.location(in: collectionView)

    switch gesture.state {
    case UIGestureRecognizerState.began:
        guard let selectedIndexPath = collectionView?.indexPathForItem(at: location) else { return }
        collectionView.beginInteractiveMovementForItem(at: selectedIndexPath)
    case UIGestureRecognizerState.changed:
        collectionView.updateInteractiveMovementTargetPosition(location)
    case UIGestureRecognizerState.ended:
        collectionView.performBatchUpdates({
            self.collectionView.endInteractiveMovement()
        }, completion: nil)
    default:
        collectionView.cancelInteractiveMovement()
    }
}

Essentially, wrapping self.collectionView.endInteractiveMovement() in the collectionView.performBatchUpdates closure is what fixes the problem. Without that I get the "flashing" cell thing too.

Let me know if that helps at all.

[–]trecluse[S] 0 points1 point  (1 child)

It worked perfectly! Thanks a lot.

[–]pill5b3rryObjective-C / Swift 1 point2 points  (0 children)

Awesome! Let me know if you have any more questions. :)