I use Auto-layout for cells (UITableViewCell and UICollectionViewCell), but have noticed a significant performance penalty when cells are reused, and I wonder what I can do to improve it.
Perhaps this is due to the way I create / configure a cell, in my application I need to show books as cells, and different genres of books have different layouts, but I only have one BookCell, I reconfigure the restrictions when a cell is created / reused for specific book based on the genre of the book.
In my opinion, in my case, the automatic layout should be slower than the fixed frame, since the following steps:
auto layout
- remove current restrictions
- add additional restrictions depending on the genre of the book
- set all tags / images for the book
I think that internally in step 2 iOS will restart the constraint resolver, and in step 3 the constraints will be re-configured (i.e. re-run the solver) to satisfy all labels and images with typing and images.
fixed layout
(there is a list of different frames for labels, images, for different genres) 1. reinstall all labels, image frames 2. Set image labels and image images
I need some time to convert all the cells of the automatic layout to use fixed frames, and about what I can come up with to improve performance:
- duplicate the common BookCell and create one cell for each genre.
- set all tags, images, up .
- Not too sure about this, should I add auto-package restrictions to the updateConstraints method or to the initializer (for example,
initWithTableViewCellStyle:reusableIdentifier: ?
Thank you so much!
ios objective-c uitableview autolayout uicollectionview
hzxu
source share