diff --git a/Source/UIScrollView+EmptyDataSet.h b/Source/UIScrollView+EmptyDataSet.h index 5dd70f27..20d5d490 100644 --- a/Source/UIScrollView+EmptyDataSet.h +++ b/Source/UIScrollView+EmptyDataSet.h @@ -205,6 +205,15 @@ */ - (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView; +/** + Asks the delegate to know if the touch should pass through the empty dataset. Default is YES. + + @param scrollView A scrollView subclass object informing the delegate. + @param view The view tapped by the user. + @return YES if touch should pass through the empty dataset. + */ +- (BOOL)emptyDataSet:(UIScrollView *)scrollView shouldAllowTouchPassThroughView:(UIView *)view; + /** Asks the delegate for image view animation permission. Default is NO. Make sure to return a valid CAAnimation object from imageAnimationForEmptyDataSet: diff --git a/Source/UIScrollView+EmptyDataSet.m b/Source/UIScrollView+EmptyDataSet.m index dc9b9fd7..35c2d3d8 100644 --- a/Source/UIScrollView+EmptyDataSet.m +++ b/Source/UIScrollView+EmptyDataSet.m @@ -325,6 +325,14 @@ - (BOOL)dzn_isScrollAllowed return NO; } +- (BOOL)dzn_isTouchAllowedToPassThrough:(UIView *)sender +{ + if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSet:shouldAllowTouchPassThroughView:)]) { + return [self.emptyDataSetDelegate emptyDataSet:self shouldAllowTouchPassThroughView:sender]; + } + return YES; +} + - (BOOL)dzn_isImageViewAnimateAllowed { if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSetShouldAnimateImageView:)]) { @@ -1040,6 +1048,17 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event return hitView; } + if ([self.superview isKindOfClass:[UIScrollView class]] && + [self.superview respondsToSelector:@selector(dzn_isTouchAllowedToPassThrough:)]) { + UIScrollView *scrollView = (UIScrollView *)self.superview; + + if (![scrollView dzn_isTouchAllowedToPassThrough:hitView]) { + return hitView; + } else { + return nil; + } + } + return nil; }