Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reload uitableview with new data caused flickering

Tags:

I added an infinite scrolling feature and realized that whenever I reload the uitableview, the view flickers..I am not sure how to fix the flickering at this point. Please help, thanks!

I did see a very similar question, but no solution to it. I tried the one the author posted, but it doesn't not work: "remove the tableview from parent view, reload data, put table view back into parent view" (UITableView reloadData - how to stop flicker)

Code:

[self.tableView reloadData]; 
like image 534
trillions Avatar asked Mar 04 '13 07:03

trillions


1 Answers

Below code worked for me like a charm!

Objective-C

[UIView performWithoutAnimation:^{    [self.tableview reloadData];    [self.tableview beginUpdates];    [self.tableview endUpdates]; }]; 

Swift 4

UIView.performWithoutAnimation {     self.tableView.reloadData()     self.tableView.beginUpdates()     self.tableView.endUpdates() } 
like image 93
Shaunak Avatar answered Sep 18 '22 12:09

Shaunak