Giter Club home page Giter Club logo

Comments (15)

dzenbot avatar dzenbot commented on June 8, 2024 16

To be totally honest, I've never tested it out with UIRefreshControl. I'm not a big fan of that control.
The scrollview it self isn't modified by the library, so UIRefreshControl should respond normally to it and display the control.

Have you tried using this API?

- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView {

    return YES;
}

Does the UIRefreshControl at least show up?

from dznemptydataset.

Artheyn avatar Artheyn commented on June 8, 2024 9

@allaire @rene-dohan Working with a CollectionView I had to implement these two delegates in order to restore the pull-to-refresh gesture (even if the emptyDataSetShouldAllowTouch is marked as true by default... Weird but it works.):

    func emptyDataSetShouldAllowScroll(_ scrollView: UIScrollView!) -> Bool {
        return true
    }

    func emptyDataSetShouldAllowTouch(_ scrollView: UIScrollView!) -> Bool {
        return true
    }

Hope it helps.

from dznemptydataset.

ushernut avatar ushernut commented on June 8, 2024 3

In case anyone made mistake like me, with the override method above, please make sure you have set self.tableview.emptyDataSetDelegate = self
Without this line, refresh control will never show up.

from dznemptydataset.

kolyan94 avatar kolyan94 commented on June 8, 2024 2

Maybe it'll help someone as a temp solution.

func emptyDataSetShouldAllowScroll(_ scrollView: UIScrollView!) -> Bool {
    return true
  }
  
func scrollViewDidScroll(_ scrollView: UIScrollView) {
    guard let view = scrollView.value(forKey: "emptyDataSetView") as? UIView else {return}
    view.frame = CGRect(x: view.frame.origin.x, y: scrollView.contentOffset.y, width: view.bounds.width, height: view.bounds.height)
  }

from dznemptydataset.

leoschweizer avatar leoschweizer commented on June 8, 2024

Addendum: I'm using the latest version available through CocoaPods (1.4.1).

from dznemptydataset.

leoschweizer avatar leoschweizer commented on June 8, 2024

That fixes the pull-to-refresh gesture. Oddly enough, the manual invocation of beginRefreshing still seems to be broken, but that would be acceptable given that the gesture is usable.

However, the empty dataset view now scrolls down during the pull gesture, which is not exactly the desired behaviour. But since offsetForEmptyDataSet: is not called during scrolling, I guess there is no way around that?

from dznemptydataset.

dzenbot avatar dzenbot commented on June 8, 2024

Not currently, no. Sorry.
Glad to know that the issue was something related to the scrollview.

Thing is, the empty data set view is nested inside of the scrollView, so it's nearly impossible not to scroll it, if the scroll is enabled.

from dznemptydataset.

leoschweizer avatar leoschweizer commented on June 8, 2024

Actually, the desired sticky behaviour can be achieved as follows:

- (void) scrollViewDidScroll:(UIScrollView *)scrollView {
    UIView *v = [scrollView emptyDataSetView];
    v.frame = CGRectMake(v.frame.origin.x, scrollView.contentOffset.y, v.frame.size.width, v.frame.size.height);
}

Which also fixes the wrong offset. Only problem with this solution is that there is no way to access the empty dataset view (I just made the accessor public for testing purposes). So unless this is something you might consider incorporating, I guess I will have to fork...

from dznemptydataset.

dzenbot avatar dzenbot commented on June 8, 2024

This seems to be a decent solution actually.
Please do fork, and submit a PR exposing the emptyDataSetView as a readOnly property. And if you can add a UIRefreshControl to any of the example projects (Countries, perhaps), that would be great for illustrating this workaround.

from dznemptydataset.

leoschweizer avatar leoschweizer commented on June 8, 2024

Unfortunately release 1.5 has broken my nice workaround, now there is a nasty glitch where the empty dataset view moves down a view pixels and immediately in the correct position again afterwards once the refreshing starts, and I don't know yet why this happens. So the pull request is postponed for the time being...

from dznemptydataset.

dzenbot avatar dzenbot commented on June 8, 2024

That's weird. If you could investigate, would be great.

from dznemptydataset.

dzenbot avatar dzenbot commented on June 8, 2024

On the meantime, I'll expose the emptyDataSetView as a readOnly property.

from dznemptydataset.

allaire avatar allaire commented on June 8, 2024

@leoschweizer Did you fix it?

from dznemptydataset.

leoschweizer avatar leoschweizer commented on June 8, 2024

@allaire No, I figured that simply using the background view of a UITableView is a much more reliable solution for my use case than working around the design of this library.

from dznemptydataset.

renetik avatar renetik commented on June 8, 2024

Tried UIRefreshControl with

- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView {
    return YES;
}

but it just don't work...

from dznemptydataset.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.