From 96daeac298e0db856d2dd4121fc89772309fbd2b Mon Sep 17 00:00:00 2001 From: Chia-Yen Lu Date: Tue, 27 Oct 2015 15:27:33 +0800 Subject: [PATCH 1/4] Add a delegate method to determine whether touches are allowed to pass through or not. --- Source/UIScrollView+EmptyDataSet.h | 9 +++++++++ Source/UIScrollView+EmptyDataSet.m | 21 +++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Source/UIScrollView+EmptyDataSet.h b/Source/UIScrollView+EmptyDataSet.h index 43655355..e5405b6c 100644 --- a/Source/UIScrollView+EmptyDataSet.h +++ b/Source/UIScrollView+EmptyDataSet.h @@ -187,6 +187,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 a96790fb..10bb7074 100644 --- a/Source/UIScrollView+EmptyDataSet.m +++ b/Source/UIScrollView+EmptyDataSet.m @@ -289,6 +289,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_isImageViewAnimateAllow { if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSetShouldAnimateImageView:)]) { @@ -973,8 +981,17 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event if ([hitView isEqual:_contentView] || [hitView isEqual:_customView]) { return hitView; } - - return nil; + + if ([self.superview isKindOfClass:[UIScrollView class]] && + [self.superview respondsToSelector:@selector(dzn_isTouchAllowedToPassThrough:)]) { + UIScrollView *scrollView = (UIScrollView *)self.superview; + + if (![scrollView dzn_isTouchAllowedToPassThrough:self]) { + return self; + } + } + + return nil; } @end From 50edd01d8e8a153b9d1411b7b8f0d949a96c4587 Mon Sep 17 00:00:00 2001 From: Chia-Yen Lu Date: Sun, 31 Jan 2016 03:31:24 +0800 Subject: [PATCH 2/4] Add a check for the true condition. --- Source/UIScrollView+EmptyDataSet.m | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/UIScrollView+EmptyDataSet.m b/Source/UIScrollView+EmptyDataSet.m index 10bb7074..3c8151d2 100644 --- a/Source/UIScrollView+EmptyDataSet.m +++ b/Source/UIScrollView+EmptyDataSet.m @@ -981,17 +981,19 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event if ([hitView isEqual:_contentView] || [hitView isEqual:_customView]) { return hitView; } - - if ([self.superview isKindOfClass:[UIScrollView class]] && - [self.superview respondsToSelector:@selector(dzn_isTouchAllowedToPassThrough:)]) { - UIScrollView *scrollView = (UIScrollView *)self.superview; - - if (![scrollView dzn_isTouchAllowedToPassThrough:self]) { - return self; - } - } - - return nil; + + 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; } @end From 3f93b4b70305cb3394304d6717bbc679d69ff147 Mon Sep 17 00:00:00 2001 From: Chia-Yen Lu Date: Sun, 31 Jan 2016 03:32:59 +0800 Subject: [PATCH 3/4] Fix the inconsistent spacings. --- Source/UIScrollView+EmptyDataSet.m | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/UIScrollView+EmptyDataSet.m b/Source/UIScrollView+EmptyDataSet.m index 3c8151d2..523b00df 100644 --- a/Source/UIScrollView+EmptyDataSet.m +++ b/Source/UIScrollView+EmptyDataSet.m @@ -291,10 +291,10 @@ - (BOOL)dzn_isScrollAllowed - (BOOL)dzn_isTouchAllowedToPassThrough:(UIView *)sender { - if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSet:shouldAllowTouchPassThroughView:)]) { - return [self.emptyDataSetDelegate emptyDataSet:self shouldAllowTouchPassThroughView:sender]; - } - return YES; + if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSet:shouldAllowTouchPassThroughView:)]) { + return [self.emptyDataSetDelegate emptyDataSet:self shouldAllowTouchPassThroughView:sender]; + } + return YES; } - (BOOL)dzn_isImageViewAnimateAllow @@ -454,15 +454,15 @@ - (void)dzn_reloadEmptyDataSet view.verticalSpace = [self dzn_verticalSpace]; // Configure Image - if (image) { - if ([image respondsToSelector:@selector(imageWithRenderingMode:)]) { - view.imageView.image = [image imageWithRenderingMode:renderingMode]; - view.imageView.tintColor = imageTintColor; - } else { - // iOS 6 fallback: insert code to convert imaged if needed - view.imageView.image = image; - } - } + if (image) { + if ([image respondsToSelector:@selector(imageWithRenderingMode:)]) { + view.imageView.image = [image imageWithRenderingMode:renderingMode]; + view.imageView.tintColor = imageTintColor; + } else { + // iOS 6 fallback: insert code to convert imaged if needed + view.imageView.image = image; + } + } // Configure title label if (titleLabelString) { From af196b12e325e162481f2200c62377ca96d31b43 Mon Sep 17 00:00:00 2001 From: Chia-Yen Lu Date: Thu, 28 Apr 2016 12:31:52 +0800 Subject: [PATCH 4/4] Fix the error caused by merging conflicts. --- Source/UIScrollView+EmptyDataSet.m | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/UIScrollView+EmptyDataSet.m b/Source/UIScrollView+EmptyDataSet.m index 74e2af0f..35c2d3d8 100644 --- a/Source/UIScrollView+EmptyDataSet.m +++ b/Source/UIScrollView+EmptyDataSet.m @@ -333,7 +333,6 @@ - (BOOL)dzn_isTouchAllowedToPassThrough:(UIView *)sender return YES; } -- (BOOL)dzn_isImageViewAnimateAllow - (BOOL)dzn_isImageViewAnimateAllowed { if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSetShouldAnimateImageView:)]) {