Created
July 26, 2017 13:04
-
-
Save e23z/c984b19b640b29d2e6057a893d85bf70 to your computer and use it in GitHub Desktop.
[Pull to Refresh (UIRefreshControl)] How to add "pull to refresh" to a table view in iOS. #mobile #swift #ios #ui #ux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var refreshControl: UIRefreshControl! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| refreshControl = UIRefreshControl() | |
| refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh") | |
| refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged) | |
| tableView.addSubview(refreshControl) // not required when using UITableViewController | |
| } | |
| func refresh(sender:AnyObject) { | |
| // Code to refresh table view | |
| } | |
| // then at some point | |
| refreshControl.endRefreshing() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment