Difference between revisions of "Swift:Using UIRefreshControl"

From Hawk Wiki
Jump to: navigation, search
(Created page with "<pre class="brush:swift"> //refreshControl is automatically defined in UITableViewController var refreshControl: UIRefreshControl? override func viewDidLoad() { super.view...")
 
(No difference)

Latest revision as of 04:04, 23 March 2015

//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()
}