Swift:Using UIRefreshControl

From Hawk Wiki
Revision as of 04:04, 23 March 2015 by Hall (Talk | contribs) (Created page with "<pre class="brush:swift"> //refreshControl is automatically defined in UITableViewController var refreshControl: UIRefreshControl? override func viewDidLoad() { super.view...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
//refreshControl is automatically defined in UITableViewController
var refreshControl: UIRefreshControl?
override func viewDidLoad() {
    super.viewDidLoad()
    
    refreshControl = UIRefreshControl()
    refreshControl?.addTarget(self, action: "fetch", forControlEvents: UIControlEvents.ValueChanged)
    tableView.insertSubview(refreshControl!, atIndex: 0)
}

//to stop refresh, call
if let rc = self.refreshControl {
    self.refreshControl!.endRefreshing()
}