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 1 commit
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 @@ -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;
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
21 changes: 19 additions & 2 deletions Source/UIScrollView+EmptyDataSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ - (BOOL)dzn_isScrollAllowed
return NO;
}

- (BOOL)dzn_isTouchAllowedToPassThrough:(UIView *)sender
{
if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSet:shouldAllowTouchPassThroughView:)]) {
Copy link
Owner

Choose a reason for hiding this comment

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

Please use the same spacing than other methods too.

return [self.emptyDataSetDelegate emptyDataSet:self shouldAllowTouchPassThroughView:sender];
}
return YES;
}

- (BOOL)dzn_isImageViewAnimateAllow
{
if (self.emptyDataSetDelegate && [self.emptyDataSetDelegate respondsToSelector:@selector(emptyDataSetShouldAnimateImageView:)]) {
Expand Down Expand Up @@ -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;
Copy link
Owner

Choose a reason for hiding this comment

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

Are you sure ![scrollView dzn_isTouchAllowedToPassThrough:self] correct?
Shouldn't we check for a true statement?

}
}

return nil;
}

@end
Expand Down