swift pull to refresh

solarenqu picture solarenqu · Apr 22, 2015 · Viewed 13.6k times · Source

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?

Answer

Hugo picture Hugo · Apr 22, 2015
self.scrollView.scrollEnabled = true
self.scrollView.alwaysBounceVertical = true

var alwaysBounceVertical: Bool // default NO. if YES and bounces is YES, even if content is smaller than bounds, allow drag vertically