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

fix false origin y of emptyDataSet view when scrollview had been scrolled #182

Open
wants to merge 1 commit 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
14 changes: 8 additions & 6 deletions Source/UIScrollView+EmptyDataSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,15 @@ - (void)dzn_reloadEmptyDataSet
DZNEmptyDataSetView *view = self.emptyDataSetView;

if (!view.superview) {
[self addSubview:view];

// Send the view all the way to the back, in case a header and/or footer is present, as well as for sectionHeaders or any other content
if (([self isKindOfClass:[UITableView class]] || [self isKindOfClass:[UICollectionView class]]) && self.subviews.count > 1) {
[self insertSubview:view atIndex:0];
}
else {
[self addSubview:view];
}
[self sendSubviewToBack:view];

// make sure the y origin of view is 0. adding it to a scrollView may have changed it
CGRect frame = view.frame;
frame.origin.y = 0;
view.frame = frame;
}

// Removing view resetting the view and its constraints it very important to guarantee a good state
Expand Down