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

DZNEmptyDataSetView Frame Issue #147

Open
wlisac opened this issue Oct 13, 2015 · 8 comments
Open

DZNEmptyDataSetView Frame Issue #147

wlisac opened this issue Oct 13, 2015 · 8 comments

Comments

@wlisac
Copy link
Contributor

wlisac commented Oct 13, 2015

DZNEmptyDataSetView sets its frame to the scroll view's bounds. I'm experiencing problems with this when reloading the DZNEmptyDataSetView while the scroll view is scrolled/scrolling.

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

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

In my specific case – the refresh control I'm using (SSPullToRefresh) adjusts the scroll view's insets and offsets while reloading and animating. This causes the DZNEmptyDataSetView to be in the "wrong" spot when I reload the DZNEmptyDataSetView during this animation.

The simplest solution for my use case is to do this:

- (void)didMoveToSuperview
{
    CGRect frame = self.superview.bounds;
    frame.origin.y = 0.0f;
    self.frame = frame;

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

Do you have any suggestions on how we could add this as an option to the project? We could possibly allow the delegate to provide a DZNEmptyDataSetView subclass to use. We could add an option for using a 0 y origin. (non relative origin?). Even just exposing the DZNEmptyDataSetView as a readonly property would allow a UIScrollView subclass to reposition the subview as needed.

Any thoughts on this would be appreciated.

@wlisac
Copy link
Contributor Author

wlisac commented Oct 13, 2015

Another idea – we could add a delegate method that provides the initial frame for positioning in the scroll view.

@wlisac
Copy link
Contributor Author

wlisac commented Oct 13, 2015

I think the last idea is the simplest solution. I've opened a pull request: #148

@dzenbot
Copy link
Owner

dzenbot commented Oct 13, 2015

👍

@wlisac
Copy link
Contributor Author

wlisac commented Oct 13, 2015

Thank you for such a quick reply and for this library.

@cooler333
Copy link

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

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

@dibelogrivaya
Copy link

This solved the problem in my case:

- (void)emptyDataSetWillAppear:(UIScrollView *)scrollView {
    scrollView.contentOffset = CGPointZero;
}

@myruntime
Copy link

@medinaonly useful

@cs13886
Copy link

cs13886 commented Feb 13, 2019

This solved the problem in my case:

- (void)emptyDataSetWillAppear:(UIScrollView *)scrollView {
    scrollView.contentOffset = CGPointZero;
}

It is very good. So clever. Thanks for share.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants