How expensive is a UITableView reloadData?

I am curious how expensive is the resource UITableView reloadData? I have an application that will make up about 10 subsequent HTTP requests, and since it receives data / experience, it reloads the tableView. As the data set grows more and more, it becomes very sluggish. I am trying to figure out if this is due to the number of times I reload the tableView or because of how I grab / parse the data.

What is the best practice in this case?

+5
source share
5 answers

Best practice is for your implementation to cellForRowAtIndexPath:do as little work as possible. In fact, this really should not do any work other than populating the instance with the UITableViewCelldata it needs to display.

You have to use cached UITableViewCell, so you don’t have to select a new cell every time. If you can parse and in a separate thread and parse the data ready for presentation, available for cellForRowAtIndexPath:, you should not have performance issues.

You did not say if you are using a custom subclass UITableViewCell, but if you are, deep view hierarchies can also pose a performance problem, since each view in the hierarchy is reversed. Bad, you can make UITableViewCells the better.

, .

+5

UITableView.h:

 - (void)reloadData;                 // reloads everything from scratch. redisplays visible rows. because we only keep info about visible rows, this is cheap. will adjust offset if table shrinks

" ".

, .

, , reloadData .

+15

, , , , .

, , ,

reloadData​​p >

cellForRowAtIndexPath

, .

+4

:

  • .
  • .

, , , .

- cellForRowAtIndexPath, , , . , , .

, , , , HTML , , .

+2

Boot To The Head .

-- Instapaper, -reloadData . , . .

+1

All Articles