Skip to content

Instantly share code, notes, and snippets.

@anuraagdjain
Created February 7, 2017 06:59
Show Gist options
  • Select an option

  • Save anuraagdjain/18b200b831f69c200f2ee5bb704cca60 to your computer and use it in GitHub Desktop.

Select an option

Save anuraagdjain/18b200b831f69c200f2ee5bb704cca60 to your computer and use it in GitHub Desktop.
Adding refresh for tableView
//Declare
@IBOutlet weak var tableView:UITableView!
var refreshControl = UIRefreshControl()
//Adding in viewDidLoad()
refreshControl.addTarget(self, action: #selector(ViewController.refreshEvents), for: .valueChanged)
tableView.addSubView(refreshControl)
//refreshEvents function
func refreshEvents(){
/*Call method to fetch new data from server
or do some logic.
*/
refreshControl.endRefreshing()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment