Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView Flickering with UIRefreshControl

I have aUITableView withUIRefreshControl defined inside the viewDidLoad: method of aUIViewController as below:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.refreshControl = [[UIRefreshControl alloc] init];
    [self.refreshControl addTarget:self action:@selector(refreshMessages) forControlEvents:UIControlEventValueChanged];
    UITableViewController *tableViewController = [[UITableViewController alloc] init];
    tableViewController.tableView = self.messagesTableView;
    tableViewController.refreshControl = self.refreshControl;  
}

- (void)refreshMessages {
    //load data items
    if ([self.refreshControl isRefreshing]) {
        [self.refreshControl endRefreshing];
    }

    [self.messagesTableView reloadData];
}

I use self sizing cell to update the cell data. On re-loading the data theUITableView flickers. Is there a way to avoid this?

Edit I have linked the video file for a sample demo. The UITableView on reload data, flickers. I use autolayout to update the dynamic cell heights.

Here is a sample code that can recreate this issue. The UITableView should be pulled to refresh. The table view is reloaded on the main queue. The cell are being resized with autolayout.


like image 630
Siddharthan Asokan Avatar asked May 19 '15 02:05

Siddharthan Asokan


2 Answers

Swift

You may want to use

extendedLayoutIncludesOpaqueBars = true

in your ViewController in order to have correct UIRefreshControl animation.

like image 190
Pavel Vavilov Avatar answered Oct 18 '22 20:10

Pavel Vavilov


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.

like image 39
DesperateLearner Avatar answered Oct 18 '22 19:10

DesperateLearner