Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView scroll lag

I have setup a collection view with 10 subviews in a cell.

The subviews are -imageview with label on it -text view -imageview -uilabel -imageview -uilabel

Initially the collection view have 15 cells displayed at the time on an iPad. No when I scroll the scroll pauses when it is time to replace the cells at the bottom or top(reusing cells). I removed the shadow but still the same issue.

So the problem happens when the old cell is reused causing a lag.

Btw, no images loaded via the network.

like image 570
naz Avatar asked May 11 '26 03:05

naz


1 Answers

I had the answer to this long time ago but for the benefit of others and who may be in the same issue.

Apart from removing shadows, you also need to remove "clear color" backgrounds. Any additional drawing that will require additional processing should be removed or replaced with an alternative. Any heavy lifting, text formatting, date formatting should be done before even showing the collection or table views. Make sure you cell only does the presenting and not processing. If you can't avoid it do the processing at another thread.

To measure the rate of the scroll you will need to use the instruments > graphics > core animation tool to measure the frame rate.

Try it and you will notice a difference.

like image 183
naz Avatar answered May 14 '26 01:05

naz