Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.
Closed
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
34 changes: 25 additions & 9 deletions Source/UIScrollView+EmptyDataSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,7 @@ - (void)dzn_reloadEmptyDataSet
UIView *customView = [self dzn_customView];

if (!view.superview) {

// Send the view to back, in case a header and/or footer is present
if ([self isKindOfClass:[UITableView class]] && self.subviews.count > 1) {
[self insertSubview:view atIndex:1];
}
else {
[self addSubview:view];
}
[self insertSubview:view atIndex:[self indexForEmptyDataSetView]];
}

// Moves all its subviews
Expand All @@ -393,7 +386,7 @@ - (void)dzn_reloadEmptyDataSet
[view.button setBackgroundImage:[self dzn_buttonBackgroundImageForState:0] forState:0];
[view.button setBackgroundImage:[self dzn_buttonBackgroundImageForState:1] forState:1];
[view.button setUserInteractionEnabled:[self dzn_isTouchAllowed]];

// Configure spacing
view.verticalSpace = [self dzn_verticalSpace];
}
Expand All @@ -416,6 +409,29 @@ - (void)dzn_reloadEmptyDataSet
}
}

- (NSInteger)indexForEmptyDataSetView {
// Send the view to back, in case a header and/or footer is present
if ([self isKindOfClass:[UITableView class]] && self.subviews.count > 1) {
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1 &&
floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
// annoying hack to work around an iOS 7 issue
__block NSUInteger *highestIndexOfTableViewFittingSubview = 0;
[self.subviews enumerateObjectsUsingBlock:^(UIView *subview, NSUInteger idx, BOOL *stop) {
if (CGRectEqualToRect(subview.bounds, self.frame)) {
highestIndexOfTableViewFittingSubview = idx;
}
}];
return highestIndexOfTableViewFittingSubview+1;
}
else {
return 1;
}
}
else {
return self.subviews.count;
}
}

- (void)dzn_invalidate
{
// Notifies that the empty dataset view will disappear
Expand Down