Skip to content

Commit 75601c7

Browse files
committed
- Reverts to sharing ownership of gesture recognizers between collection view and layout.
1 parent e740a3c commit 75601c7

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
@property (assign, nonatomic) CGFloat scrollingSpeed;
1313
@property (assign, nonatomic) UIEdgeInsets scrollingTriggerEdgeInsets;
14-
@property (weak, nonatomic, readonly) UILongPressGestureRecognizer *longPressGestureRecognizer;
15-
@property (weak, nonatomic, readonly) UIPanGestureRecognizer *panGestureRecognizer;
14+
@property (strong, nonatomic, readonly) UILongPressGestureRecognizer *longPressGestureRecognizer;
15+
@property (strong, nonatomic, readonly) UIPanGestureRecognizer *panGestureRecognizer;
1616

1717
- (void)setUpGestureRecognizersOnCollectionView __attribute__((deprecated("Calls to setUpGestureRecognizersOnCollectionView method are not longer needed as setup are done automatically through KVO.")));
1818

LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,23 @@ - (void)setDefaults {
6767
}
6868

6969
- (void)setupCollectionView {
70-
UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
71-
action:@selector(handleLongPressGesture:)];
72-
longPressGestureRecognizer.delegate = self;
73-
[self.collectionView addGestureRecognizer:longPressGestureRecognizer];
70+
_longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
71+
action:@selector(handleLongPressGesture:)];
72+
_longPressGestureRecognizer.delegate = self;
73+
[self.collectionView addGestureRecognizer:_longPressGestureRecognizer];
7474

7575
// Links the default long press gesture recognizer to the custom long press gesture recognizer we are creating now
7676
// by enforcing failure dependency so that they doesn't clash.
7777
for (UIGestureRecognizer *gestureRecognizer in self.collectionView.gestureRecognizers) {
7878
if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
79-
[gestureRecognizer requireGestureRecognizerToFail:longPressGestureRecognizer];
79+
[gestureRecognizer requireGestureRecognizerToFail:_longPressGestureRecognizer];
8080
}
8181
}
82-
_longPressGestureRecognizer = longPressGestureRecognizer;
8382

84-
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self
85-
action:@selector(handlePanGesture:)];
86-
panGestureRecognizer.delegate = self;
87-
[self.collectionView addGestureRecognizer:panGestureRecognizer];
88-
_panGestureRecognizer = panGestureRecognizer;
83+
_panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self
84+
action:@selector(handlePanGesture:)];
85+
_panGestureRecognizer.delegate = self;
86+
[self.collectionView addGestureRecognizer:_panGestureRecognizer];
8987
}
9088

9189
- (id)init {

0 commit comments

Comments
 (0)