diff --git a/Source/ASCollectionNode.h b/Source/ASCollectionNode.h index 15a3c52a6..fcce974b9 100644 --- a/Source/ASCollectionNode.h +++ b/Source/ASCollectionNode.h @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN * ASCollectionNode is a node based class that wraps an ASCollectionView. It can be used * as a subnode of another node, and provide room for many (great) features and improvements later on. */ -@interface ASCollectionNode : ASDisplayNode +@interface ASCollectionNode : ASDisplayNode - (instancetype)init NS_UNAVAILABLE; diff --git a/Source/ASCollectionNode.mm b/Source/ASCollectionNode.mm index 51cb7d330..5fbdff326 100644 --- a/Source/ASCollectionNode.mm +++ b/Source/ASCollectionNode.mm @@ -1040,6 +1040,38 @@ - (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode; return result; } +#pragma mark - UIGestureRecognizerDelegate Methods +// The value returned below are default implementation of UIKit's UIGestureRecognizerDelegate +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer +{ + return YES; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch +{ + return YES; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivePress:(UIPress *)press +{ + return YES; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + return NO; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + return NO; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + return NO; +} + #pragma mark - Private methods - (void)_configureCollectionViewLayout:(UICollectionViewLayout *)layout diff --git a/Source/ASCollectionView.h b/Source/ASCollectionView.h index 6e9d343dc..1b250a21f 100644 --- a/Source/ASCollectionView.h +++ b/Source/ASCollectionView.h @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note ASCollectionNode is strongly recommended over ASCollectionView. This class exists for adoption convenience. */ -@interface ASCollectionView : UICollectionView +@interface ASCollectionView : UICollectionView /** * Returns the corresponding ASCollectionNode diff --git a/Source/ASCollectionView.mm b/Source/ASCollectionView.mm index d8dc9fdfe..669c14484 100644 --- a/Source/ASCollectionView.mm +++ b/Source/ASCollectionView.mm @@ -317,7 +317,8 @@ - (instancetype)_initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionV [self registerClass:[_ASCollectionViewCell class] forCellWithReuseIdentifier:kReuseIdentifier]; [self _configureCollectionViewLayout:layout]; - + + self.panGestureRecognizer.delegate = self; return self; } @@ -2518,4 +2519,35 @@ - (NSArray *)accessibilityElements return [super accessibilityElements]; } +#pragma mark - UIGestureRecognizerDelegate Method +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer +{ + return [self.collectionNode gestureRecognizerShouldBegin:gestureRecognizer]; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch +{ + return [self.collectionNode gestureRecognizer:gestureRecognizer shouldReceiveTouch:touch]; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivePress:(UIPress *)press +{ + return [self.collectionNode gestureRecognizer:gestureRecognizer shouldReceivePress:press]; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + return [self.collectionNode gestureRecognizer:gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer]; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + return [self.collectionNode gestureRecognizer:gestureRecognizer shouldRequireFailureOfGestureRecognizer:otherGestureRecognizer]; +} + +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer +{ + return [self.collectionNode gestureRecognizer:gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:otherGestureRecognizer]; +} + @end