Skip to content

Commit 9558dd7

Browse files
committed
Fixed bug of multiple cells on rapid tapping.
Setting the longPressGestureRecognizer’s minimumPressDuration property to 0, and then rapidly tapping on cells can cause extra cells to show up that are not able to be moved in any way. This fixes that issue by disabling the longPressGestureRecognizer until the animation that happens when the long press ends.
1 parent 547ea3f commit 9558dd7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
345345

346346
UICollectionViewLayoutAttributes *layoutAttributes = [self layoutAttributesForItemAtIndexPath:currentIndexPath];
347347

348+
self.longPressGestureRecognizer.enabled = NO;
349+
348350
__weak typeof(self) weakSelf = self;
349351
[UIView
350352
animateWithDuration:0.3
@@ -358,6 +360,9 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer
358360
}
359361
}
360362
completion:^(BOOL finished) {
363+
364+
self.longPressGestureRecognizer.enabled = YES;
365+
361366
__strong typeof(self) strongSelf = weakSelf;
362367
if (strongSelf) {
363368
[strongSelf.currentView removeFromSuperview];

0 commit comments

Comments
 (0)