Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.
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
10 changes: 9 additions & 1 deletion Source/UIScrollView+EmptyDataSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
*
* @return image animation
*/
- (CAAnimation *) imageAnimationForEmptyDataSet:(UIScrollView *) scrollView;
- (CAAnimation *)imageAnimationForEmptyDataSet:(UIScrollView *) scrollView;

/**
Asks the data source for the title to be used for the specified button state.
Expand Down Expand Up @@ -143,6 +143,14 @@
- (CGPoint)offsetForEmptyDataSet:(UIScrollView *)scrollView DEPRECATED_MSG_ATTRIBUTE("Use -verticalOffsetForEmptyDataSet:");
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView;

/**
Asks the data source for an initial frame for the empty data set view. Default is the scroll view's bounds.

@param scrollView A scrollView subclass object informing the delegate.
@return The initial frame for the empty data set view.
*/
- (CGRect)initialFrameForEmptyDataSet:(UIScrollView *)scrollView;

/**
Asks the data source for a vertical space between elements. Default is 11 pts.

Expand Down
14 changes: 12 additions & 2 deletions Source/UIScrollView+EmptyDataSet.m
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ - (CGFloat)dzn_verticalOffset
return offset;
}

- (CGRect)dzn_initialFrame
{
CGRect frame = self.bounds;

if (self.emptyDataSetSource && [self.emptyDataSetSource respondsToSelector:@selector(initialFrameForEmptyDataSet:)]) {
frame = [self.emptyDataSetSource initialFrameForEmptyDataSet:self];
}
return frame;
}

- (CGFloat)dzn_verticalSpace
{
if (self.emptyDataSetSource && [self.emptyDataSetSource respondsToSelector:@selector(spaceHeightForEmptyDataSet:)]) {
Expand Down Expand Up @@ -413,6 +423,8 @@ - (void)dzn_reloadEmptyDataSet
DZNEmptyDataSetView *view = self.emptyDataSetView;

if (!view.superview) {
view.frame = [self dzn_initialFrame];

// 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];
Expand Down Expand Up @@ -681,8 +693,6 @@ - (instancetype)init

- (void)didMoveToSuperview
{
self.frame = self.superview.bounds;

[UIView animateWithDuration:0.25
animations:^{_contentView.alpha = 1.0;}
completion:NULL];
Expand Down