I have a uitableview that loads fairly large images in each cell and the cell heights vary depending on the size of the image. Scrolling performance is decent, but can sometimes be jerky.
I found these tips I found on the FieryRobot blog:
glassy-scrolling-with-uitableview
more-glassy-scrolling-with-uitableview
Does anyone have any tips for improving uitableview scrolling performance?
#1 performance killer for UITableView scrolling is drawing shadows on any cell view layer, so if scrolling performance matters then don't do shadows unless basically it doesn't slow down your main thread.
thought this had to be said since none of the accepted answers made mention of shadows and layers. :+)
UITableViewCell
'sdrawRect:
if possible avoid subviews at all costs (or if you require the standard accessibility functionality, the content view'sdrawRect:
)UITableViewCell
's layer opaque (same goes for the content view if you have one)UITableView
examples/documentationUIImage
sUITableViewCell
, don't use a Nib, write it in code instead. It's much faster than loading Nib files.Any problem with
UITableView
scrolling performance can be solved using techniques already described in other answers. However many a times sluggish performance is caused by something inherently erroneous, or repetitive.The fact that
UITableView
reuses the cells, and the fact that each cell may need its own image - together makes the solution bit complex. From how it's being solved the general way, here I summarize things that should be taken care of:[tableView reloaddata]
cellForRowAtIndexPath
, include code that will set data (text) from correct data model object of the array.To avoid problems, refer to this tutorial about lazy loading of images inside table view.
The developer behind Tweetie has written extensively about this and has some code that demonstrates how it was done for that app. Basically, he/she advocates one custom view per table cell, and drawing it manually (rather than subviewing with Interface Builder, among other options).
fast-scrolling-in-tweetie-with-uitableview
Also, Apple has updated its own sample code for TableView in its TableViewSuite tutorials (maybe in response to this?)
TableViewSuite