UIRefreshControl – beginRefreshing not working when UITableViewController is inside UINavigationController

It seems that if you start refreshing programmatically, you have to scroll the table view yourself, say, by changing contentoffset [self.tableView setContentOffset:CGPointMake(0, -self.refreshControl.frame.size.height) animated:YES]; I would guess the reason for this is that it could be undesirable to scroll to the refresh control when user is in the middle/bottom of the table view? Swift 2.2 … Read more

How to use pull to refresh in Swift?

Pull to refresh is built in iOS. You could do this in swift like let refreshControl = UIRefreshControl() override func viewDidLoad() { super.viewDidLoad() refreshControl.attributedTitle = NSAttributedString(string: “Pull to refresh”) refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged) tableView.addSubview(refreshControl) // not required when using UITableViewController } @objc func refresh(_ sender: AnyObject) { // Code to refresh table view } … Read more

UIRefreshControl without UITableViewController

On a hunch, and based on DrummerB’s inspiration, I tried simply adding a UIRefreshControl instance as a subview to my UITableView. And it magically just works! UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged]; [self.myTableView addSubview:refreshControl]; This adds a UIRefreshControl above your table view and works as expected without having to use a … Read more