From 86a853ea09fc39085a9179106167a182978a3cc7 Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Thu, 6 Dec 2018 07:57:54 -0800 Subject: [PATCH] Forward hitTest:withEvent and piontInside:withEvent: to node within _ASCollectionViewCell (#1268) --- Source/Details/_ASCollectionViewCell.mm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Source/Details/_ASCollectionViewCell.mm b/Source/Details/_ASCollectionViewCell.mm index bd36d56bf..39afa167d 100644 --- a/Source/Details/_ASCollectionViewCell.mm +++ b/Source/Details/_ASCollectionViewCell.mm @@ -8,6 +8,7 @@ // #import +#import #import #import @@ -94,6 +95,29 @@ - (void)layoutSubviews self.node.frame = self.contentView.bounds; } +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event +{ + /** + * The documentation for hitTest:withEvent: on an UIView explicitly states the fact that: + * it ignores view objects that are hidden, that have disabled user interactions, or have an + * alpha level less than 0.01. + * To be able to determine if the collection view cell should skip going further down the tree + * based on the states above we use a valid point within the cells bounds and check the + * superclass hitTest:withEvent: implementation. If this returns a valid value we can go on with + * checking the node as it's expected to not be in one of these states. + */ + if (![super hitTest:self.bounds.origin withEvent:event]) { + return nil; + } + + return [self.node hitTest:point withEvent:event]; +} + +- (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event +{ + return [self.node pointInside:point withEvent:event]; +} + @end /**