Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Thomas France
4,139 PointsHow to implement "pull to refresh on a standard view (not tabke view) ?
I am practising and trying to avoid making the refresh of the stormy app through the button. I checked on the web and I can only find "pull to refresh" implementation on a UITableView, is there a way to do it on a regular view?
Thanks
1 Answer
Martin Wildfeuer
Courses Plus Student 11,071 PointsYour view does not necessarily have to be a UITableView, but I would recommend to use a UIScrollView (that's what a UITableView is under the hood anyhow). That is, embed your view in a UIScrollView, this way you should be able to use SVPullToRefresh - Objective-C, or Refresher - Swift, for example.
// SVPullToRefresh example
[yourScrollView addPullToRefreshWithActionHandler:^{
// prepend data to dataSource, insert cells at top of table view
// call [yourScrollView.pullToRefreshView stopAnimating] when done
}];
Admittedly, this is untested and rather intended to give you an idea. I have never used pull-to-refresh without a table/collection view, so let me know if that works :)