Permalink
Browse files

- Add codes that prevent clashing of events between default and cust…

…om long press gesture recognizer for collection view.
  • Loading branch information...
1 parent 6cd339a commit 42f6c5384a7f4e090235b92808f2a8ecebe5df36 @lxcid committed Oct 11, 2012
Showing with 14 additions and 0 deletions.
  1. +7 −0 LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m
  2. +7 −0 README.md
View
7 LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m
@@ -30,6 +30,13 @@ @implementation LXReorderableCollectionViewFlowLayout
- (void)setUpGestureRecognizersOnCollectionView {
UILongPressGestureRecognizer *theLongPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)];
+ // Links the default long press gesture recognizer to the custom long press gesture recognizer we are creating now
+ // by enforcing failure dependency so that they doesn't clash.
+ for (UIGestureRecognizer *theGestureRecognizer in self.collectionView.gestureRecognizers) {
+ if ([theGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
+ [theGestureRecognizer requireGestureRecognizerToFail:theLongPressGestureRecognizer];
+ }
+ }
theLongPressGestureRecognizer.delegate = self;
[self.collectionView addGestureRecognizer:theLongPressGestureRecognizer];
self.longPressGestureRecognizer = theLongPressGestureRecognizer;
View
7 README.md
@@ -35,6 +35,13 @@ Getting Started
5. Setup your collection view accordingly to your need, run and see it in action! :D
+Limitations
+===========
+
+Collection view come with a default long press gesture recognizer and because we defined our own custom long press gesture recognizer, we created a link between them that requires the custom one to fails before the default one can began.
+
+In short, we took over the responsibility of long press gesture with the custom one from the default one. You can disable the custom long press gesture recognizer with the following code snippet, `self.longPressGestureRecognizer.enabled = YES`, which enabled the default behavior again.
+
Requirements
============

0 comments on commit 42f6c53

Please sign in to comment.