From a33b1d382446fab5fc755a0046aab7c576716559 Mon Sep 17 00:00:00 2001 From: lazy-iOS2 Date: Fri, 27 Nov 2015 16:13:17 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DSupplementaryViews?= =?UTF-8?q?=E5=8F=AF=E8=A7=A6=E5=8F=91=E6=89=8B=E5=8A=BF,=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=BC=95=E8=B5=B7=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Helpers/LSCollectionViewHelper.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m index 77929f6..f199403 100644 --- a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m +++ b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m @@ -131,6 +131,8 @@ - (void)setupScrollTimerInDirection:(_ScrollingDirection)direction { } } +#pragma mark - gesture delegate + - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if([gestureRecognizer isEqual:_panPressGestureRecognizer]) { @@ -152,6 +154,14 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni return NO; } +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ + CGPoint touchPoint = [touch locationInView:_collectionView]; + if (![_collectionView indexPathForItemAtPoint:touchPoint]){ + return NO; + } + return YES; +} + - (NSIndexPath *)indexPathForItemClosestToPoint:(CGPoint)point { NSArray *layoutAttrsInRect; From 8aca22bd2f7941003e8033e99defaafc47682302 Mon Sep 17 00:00:00 2001 From: lazy-iOS2 Date: Fri, 27 Nov 2015 16:27:56 +0800 Subject: [PATCH 2/2] sorry,forgot set delegate for longPressGesture --- DraggableCollectionView/Helpers/LSCollectionViewHelper.m | 1 + 1 file changed, 1 insertion(+) diff --git a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m index f199403..b55e9e5 100644 --- a/DraggableCollectionView/Helpers/LSCollectionViewHelper.m +++ b/DraggableCollectionView/Helpers/LSCollectionViewHelper.m @@ -59,6 +59,7 @@ - (id)initWithCollectionView:(UICollectionView *)collectionView initWithTarget:self action:@selector(handleLongPressGesture:)]; [_collectionView addGestureRecognizer:_longPressGestureRecognizer]; + _longPressGestureRecognizer.delegate = self; _panPressGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];