Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

UIRefreshControl with inverted set to true? #343

Closed
gdroel opened this issue Jan 4, 2016 · 7 comments
Closed

UIRefreshControl with inverted set to true? #343

gdroel opened this issue Jan 4, 2016 · 7 comments

Comments

@gdroel
Copy link

gdroel commented Jan 4, 2016

Hey all,

I'm trying to add a UIRefreshControl to my SLKTextViewController, but it is to be added to the bottom of the screen, rather than the top. I am guessing that this is a result of the inverted property being set to true. Maybe not really a bug, but this would be nice to support. Any ideas on how to make this work?

@dzenbot
Copy link

dzenbot commented Jan 4, 2016

You can try forcing the refresh control to work from the bottom, ence top when using the inverted mode. There are a few OSS solutions out there, but this one seems nice: https://github.com/vlasov/CCBottomRefreshControl

Related to #55

@gdroel
Copy link
Author

gdroel commented Jan 4, 2016

Thanks for the suggestion. I've actually tried CCBottomRefreshControl, but the refresh icon appears on top of the first row of the tableview for some reason. Maybe I'll try some other libraries.

@dzenbot
Copy link

dzenbot commented Jan 6, 2016

Unfortunately the library doesn't have much control over this, when inverted is on. I hope you can figure it out 💪

@dzenbot dzenbot closed this as completed Jan 6, 2016
@gdroel
Copy link
Author

gdroel commented Jan 6, 2016

I had to put my own refresh spinner in a table footer view to make it work. Here's some code:

    override func scrollViewDidEndDecelerating(scrollView: UIScrollView!) {

        let scrollOffset : CGFloat = scrollView.contentOffset.y
        let scrollHeight : CGFloat = scrollView.frame.size.height

        let scrollContentSizeHeight : CGFloat = scrollView.contentSize.height + scrollView.contentInset.bottom

        if (scrollOffset + scrollHeight) >= scrollContentSizeHeight {

            UIView.animateWithDuration(0.3, animations: { () -> Void in
                //73 is my horrible magic number, it represents how far you have to pull down to refresh
                scrollView.contentOffset = CGPointMake(0, scrollView.contentOffset.y - 73)
                //call your reloading function here
                //animate your spinner in the footer view here
            })
        }

    }

@jacortinas
Copy link

@gdroel Is it possible to provide a more comprehensive example of a working refresh control with this library? I've been looking everywhere and I can't find anything but references that it's possible.

@gdroel
Copy link
Author

gdroel commented Feb 17, 2016

Sorry @jacortinas, this is the only way i've been able to implement it. Definitely would love to see a library for this.

@develth
Copy link

develth commented May 12, 2017

anyone solved it already?

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

4 participants