Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView choppy scrolling when appending new cells coming back from network

In scrollViewDidScroll, I check if the table view is scroll close enough to the bottom, if it is, a network request is executed to fetch new data from the server, and when the network request is successful I updated the data model and then updated the tableView by calling [tableView reloadData].

The symptom is the scrolling performance is choppy at the moment when the network request is finished and new items get added to the table.

Does anyone know what could cause the issue?

like image 433
Pinch Avatar asked Nov 29 '25 03:11

Pinch


1 Answers

don't reload the whole table view

just add your data to dataSource and call [tableView:insertRowsAtIndexPaths:withRowAnimation]

Example ..

// addNewDataToDataSource(data)

[tableView beginUpdates];
[tableView insertRowsAtIndexPaths:indexes withRowAnimation:UITableViewRowAnimationAutomatic];
[tableView endUpdates];
like image 138
Roger Avatar answered Nov 30 '25 16:11

Roger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!