Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Add a delegate method to determine whether touches are allowed to pass through or not. #158

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Source/UIScrollView+EmptyDataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate you adding the docs and following the same syntaxes 💪


/**
Asks the delegate for image view animation permission. Default is NO.
Make sure to return a valid CAAnimation object from imageAnimationForEmptyDataSet:
Expand Down
19 changes: 19 additions & 0 deletions Source/UIScrollView+EmptyDataSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -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:)]) {
Expand Down Expand Up @@ -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;
}

Expand Down