i have my refreshcontroller
with a scrollview
..
self.refreshControl = UIRefreshControl()
self.refreshControl.attributedTitle = NSAttributedString(string: "Frissítéshez húzzad! :)")
self.refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)
self.scrollView.addSubview(refreshControl)
func refresh(sender:AnyObject)
{
//my refresh code here..
self.refreshControl.endRefreshing()
}
I'm adding as a subview
to a scrollView
. It's working when the page content is overflowing
the screen. but the issue arise when i haven't received much data and it's not overflowing
, the pull and refresh
function is not working. :(
I'm not using tableview
.
Can anybody help me how to solve this problem?
iOS 10 Update
alwaysBounceVertical
is not entirely true, andrefreshControl
has been introduced:bounces
is always required ifcontentSize
is smaller thanframe
alwaysBounceVertical
is also required for small contentUIScrollView
of the existence of aUIRefreshControl
usingrefreshControl
- iOS 10
UIRefreshControl
is now supported byUIScrollView
, usingrefreshControl
just likeUITableView
in previous OS.This means that the drag & pull down experience, is flawless, without drift.
Follow the tap + drag on the white arrow in the animation below: they stay in sync
↻ replay animation
- iOS 9 and earlier
You can add a
UIRefreshControl
manually to aUIScrollView
, but that view has no awareness of such an element, and the pull to refresh tends to drift.Notice how much harder it is to pull to refresh on the animation below: scrolling of the white arrow drifts, and requires a much greater distance to trigger the control
↻ replay animation
Bypass
refreshControl
OS discrepancies with this scroll viewextension
:► Find this solution on GitHub.
This UIRefreshControl is not supposed to work for UIScrollView. It is supposed to be linked with a table through an associated table view controller object.
UIRefreshControl Class Reference
Yes We can use refresh control to UIScrollView, UITableview, UicollectionVIew..
Here is the code for PULL TO REFRESH,