UITableView Flickering with UIRefreshControl
I guess the issue is using estimatedHeight & UITableViewAutomaticDimension along with uitableview's reloadData. This has been reported here
The delay would work but its still not the right way to achieve it unless you want a hackish work around.
Swift
You may want to use
extendedLayoutIncludesOpaqueBars = true
in your ViewController in order to have correct UIRefreshControl animation.
I got the same issue today and I managed to solve the problem using CATransaction, here is a code snippet in Swift, executed within a UITableViewController :
CATransaction.begin()
CATransaction.setCompletionBlock { () -> Void in
/*wait for endRefreshing animation to complete
before reloadData so table view does not flicker to top
then continue endRefreshing animation */
self.tableView.reloadData()
}
self.refreshControl!.endRefreshing()
CATransaction.commit()
The problem is that you are calling -reloadData and -endRefreshing together. Both want to update the view. You need to separate them a bit.
One of these options will work, depending on where you want to see the cells update:
[self.tableView reloadData];
[self.refreshControl performSelector:@selector(endRefreshing) withObject:nil afterDelay:0.5];
[self.refreshControl endRefreshing];
[self.tableView performSelector:@selector(reloadData) withObject:nil afterDelay:0.5];
Probably you need less delay with the first option. Even 0.0 seconds seemed to work in your example code. That's enough to get the -endRefreshing animation on the next screen refresh.