Scroll to refresh as button press iOS - non-UITableView

158 Views Asked by At

Sorry for the noob question but is there a way to use the "scroll to refresh" gesture as a button press?

Basically I have a simple app set up to demonstrate 1 aspect of a new project I am working on. Currently it is set to update some data based on a UIButton press, but I think it would be slick to do it with a swipe down gesture.

Everything I've been reading seems to show the default scroll to refresh / UIRefreshControl is only for UITableView elements.

Is there a way to us this type of gesture to emulate a button press?

1

There are 1 best solutions below

0
On

You can try SVPullToRefresh which works on any UIScrollView subclass.

If you want to implement it yourself, you can use key-value observing to observe the scrollView's contentOffset property or check it in the scrollViewDidScroll: delegate method. From there, you can display the view you want above the scroll view's contents, and trigger whatever action you want based on the content offset.