From 7ef22be87233059768e0d6e44c5cf9f97e9640a0 Mon Sep 17 00:00:00 2001 From: Colin Humber Date: Fri, 30 Jun 2017 22:37:25 -0600 Subject: [PATCH] Revert #259 If a custom view has a UIControl subclass, the -gestureRecognizer:shouldReceiveTouch: call is necessary to allow touches to pass through to the control immediately. Without this call, touches are delayed, and the touch up action on the control doesn't fire unless the control is tapped for an extended period of time. The call here is checking to see if the tap gesture on the DZNEmptyDataSetView should receive touches. If the tapped view is a UIControl, the gesture recognizer shouldn't receive any touches and should instead pass them along to the UIControl for processing. --- Source/UIScrollView+EmptyDataSet.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/UIScrollView+EmptyDataSet.m b/Source/UIScrollView+EmptyDataSet.m index 27d0a3a7..63670a53 100644 --- a/Source/UIScrollView+EmptyDataSet.m +++ b/Source/UIScrollView+EmptyDataSet.m @@ -685,6 +685,13 @@ - (void)swizzleIfPossible:(SEL)selector #pragma mark - UIGestureRecognizerDelegate Methods +// This is necessary to allow touches to pass through to any UIControl that is tapped within a custom view. Otherwise, +// the tap gesture on the DZNEmptyDataSetView gets the touch first which isn't the desired behaviour. The tap gesture +// should only get touch events if the view that was tapped is not a UIControl +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { + return ![touch.view isKindOfClass:[UIControl class]]; +} + - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { if ([gestureRecognizer.view isEqual:self.emptyDataSetView]) {