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

fix: DZNEmptyDataSet is overriding scrollEnabled #198 #430

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions Source/UIScrollView+EmptyDataSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ - (void)prepareForReuse;
static char const * const kEmptyDataSetSource = "emptyDataSetSource";
static char const * const kEmptyDataSetDelegate = "emptyDataSetDelegate";
static char const * const kEmptyDataSetView = "emptyDataSetView";

static BOOL tempScrollEnabled;
#define kEmptyImageViewAnimationKey @"com.dzn.emptyDataSet.imageViewAnimation"

@interface UIScrollView () <UIGestureRecognizerDelegate>
Expand Down Expand Up @@ -393,6 +393,8 @@ - (void)dzn_didTapDataButton:(id)sender
- (void)setEmptyDataSetSource:(id<DZNEmptyDataSetSource>)datasource
{
if (!datasource || ![self dzn_canDisplay]) {
// Record scroll permission
tempScrollEnabled = self.scrollEnabled;
[self dzn_invalidate];
}

Expand All @@ -410,6 +412,8 @@ - (void)setEmptyDataSetSource:(id<DZNEmptyDataSetSource>)datasource
- (void)setEmptyDataSetDelegate:(id<DZNEmptyDataSetDelegate>)delegate
{
if (!delegate) {
// Record scroll permission
tempScrollEnabled = self.scrollEnabled;
[self dzn_invalidate];
}

Expand Down Expand Up @@ -536,6 +540,8 @@ - (void)dzn_reloadEmptyDataSet
[view layoutIfNeeded];
}];

// Record scroll permission
tempScrollEnabled = self.scrollEnabled;
// Configure scroll permission
self.scrollEnabled = [self dzn_isScrollAllowed];

Expand Down Expand Up @@ -572,7 +578,8 @@ - (void)dzn_invalidate
[self setEmptyDataSetView:nil];
}

self.scrollEnabled = YES;
// restore scroll permission
self.scrollEnabled = tempScrollEnabled;

// Notifies that the empty dataset view did disappear
[self dzn_didDisappear];
Expand Down