Monday, 26 August 2013

How to improve performance of UICollectionView with custom cell sizes?

How to improve performance of UICollectionView with custom cell sizes?

As the user types, I am retrieving results (text) by traversing a local
word graph in a background thread. Each keystroke cancels the previous
operation. If the operation completes, the data source is updated and
reloadData is called on the main thread. This works great and is very fast
(as fast as the user can type), even when tens of thousands of results are
returned.
To customize the size of each collection view cell, I implemented
sizeForItemAtIndexPath for the UICollectionViewDelegateFlowLayout
delegate. Unfortunately, this results in a small, but noticeable lag when
the user types. To be sure the time was not lost in my size calculation
logic, I tried just returning a fixed size, but it still killed
performance. I am surprised at this because there are only ~120 cells or
so on the screen at any given time. When commenting out this method, the
response time is again immediate, even for very large data sets.
Any ideas for improving the performance of UICollectionView with custom
cell sizes?
Thanks

No comments:

Post a Comment