UICollectionView with self sizing cells exhibits sizing problems on cell insert and delete

Originator:maximilianfc
Number:rdar://46236635 Date Originated:26/11/2018
Status:New Resolved:
Product:iOS SDK UIKit Product Version:12.1
Classification: Reproducible:Always
 
Summary: When inserting or removing self sizing cells from a UICollectionView, the existing cells adopt an incorrect size and the layout adopts an incorrect state.


Steps to Reproduce:
1. Set up a UICollectionViewController (or UIViewController with a UICollectionView). Give the it a flow layout with estimated item size.
2. Set up a cell that requires a dynamic size. For example a cell with a multiline label.
3. Use this cell in the collection view and set varying text lengths on the label during the cellForItem data source calls.
4. Insert cells.
5. Observe strange behaviour (see below)
6. Delete cells.
7. Observe strange behaviour (see below)


Expected Results:
Existing cells should keep their correct size during animation. After animation the cells should all have the correct size.

Actual Results:
The existing cells adopt the estimated size and animate to a different larger size. When animation completes they snap to a different size again, which is often incorrect. The cell being inserted has an incorrect size.

Version/Build:
Xcode 10.1 (10B61), iOS 12.1

Configuration:
See attached example project demonstrating the issue with 100% reproducibility.

Comments

Example project here: https://drive.google.com/open?id=1AsmeffFjhYBb7ELEkjFXvIXeSAXRf8Jz

By maximilianfc at Nov. 26, 2018, 6:26 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!