Skip to content
Browse files

Fixes issue #9 with recognizing taps while scrolling

Also exposes scrollView (as this is *really* useful sometimes)
Also adds UIViewAnimationOptionAllowUserInteraction for iOS4, so that animations don't block the whole user interface.
  • Loading branch information...
1 parent fd18876 commit 487b4afcd6a80490c3a1a287ae10b68009e395e0 @steipete steipete committed with
Showing with 7 additions and 3 deletions.
  1. +3 −1 GMGridView/API/GMGridView.h
  2. +4 −2 GMGridView/API/GMGridView.m
View
4 GMGridView/API/GMGridView.h
@@ -65,7 +65,7 @@ typedef enum
@property (nonatomic, getter=isEditing) BOOL editing; // Default is NO - When set to YES, all gestures are disabled and delete buttons shows up on cells
// Customizing Options
-@property (nonatomic, gm_weak) UIView *mainSuperView; // Default is self
+@property (nonatomic, gm_weak) UIView *mainSuperView; // Default is self
@property (nonatomic) GMGridViewStyle style; // Default is GMGridViewStyleSwap
@property (nonatomic) NSInteger itemSpacing; // Default is 10
@property (nonatomic) BOOL centerGrid; // Default is YES
@@ -75,6 +75,8 @@ typedef enum
@property (nonatomic) BOOL showsVerticalScrollIndicator; // Default is YES
@property (nonatomic) BOOL showsHorizontalScrollIndicator; // Default is YES
+@property (nonatomic, strong) UIScrollView *scrollView;
+
// Reusable cells
- (GMGridViewCell *)dequeueReusableCell;
View
6 GMGridView/API/GMGridView.m
@@ -144,6 +144,7 @@ @implementation GMGridView
@synthesize minEdgeInsets = _minEdgeInsets;
@synthesize showFullSizeViewWithAlphaWhenTransforming;
@synthesize editing = _editing;
+@synthesize scrollView = _scrollView;
@synthesize itemsSubviewsCacheIsValid = _itemsSubviewsCacheIsValid;
@synthesize itemSubviewsCache;
@@ -402,15 +403,16 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
BOOL valid = YES;
+ BOOL isScrolling = _scrollView.isDragging || _scrollView.isDecelerating;
if (gestureRecognizer == _tapGesture)
{
CGPoint locationTouch = [_tapGesture locationInView:_scrollView];
- valid = !self.isEditing && [self.layoutStrategy itemPositionFromLocation:locationTouch] != GMGV_INVALID_POSITION;
+ valid = !isScrolling && !self.isEditing && [self.layoutStrategy itemPositionFromLocation:locationTouch] != GMGV_INVALID_POSITION;
}
else if (gestureRecognizer == _sortingLongPressGesture)
{
- valid = !self.isEditing && (self.sortingDelegate != nil);
+ valid = !isScrolling && !self.isEditing && (self.sortingDelegate != nil);
}
else if (gestureRecognizer == _sortingPanGesture)
{

0 comments on commit 487b4af

Please sign in to comment.
Something went wrong with that request. Please try again.