UICollectionView self sizing resets to estimated / unexpected heights
Originator: | kellerbryan19 | ||
Number: | rdar://44241734 | Date Originated: | 09/07/2018 |
Status: | Open | Resolved: | No |
Product: | UIKit | Product Version: | iOS 12 |
Classification: | Bug | Reproducible: | Yes |
Summary: `UICollectionView` sets all items to an estimated / unexpected height during batch updates if cells have the same width as the collection view. If cells are even 1 pixel less than the collection view's width, animations look correct. Attached is a sample project that demonstrates this bug in flow layout, but the issue occurs in all UICollectionViewLayout subclasses that use preferredAttributes / self sizing cells. Steps to Reproduce: 1. Open sample project 2. Click to remove the item at index 1 [Observe animation issue] 3. Click again to insert that item back at index 1 [Observe animation issue] 4. Change ViewController.swift:73 from `cell.widthConstraint?.constant = collectionView.bounds.width` to `cell.widthConstraint?.constant = collectionView.bounds.width - 1`. [This makes each cell 1 pixel less wide than the collection view. The issue will no longer occur if steps 1-3 are repeated.] Expected Results: Animations should work correctly, even if a cell's width == the collection view's width. Actual Results: Animations are broken. Version/Build: iOS 9, 10, 11, and 12 Sample project: https://drive.google.com/file/d/1Nay8jkGXwwmJUQKUE-FcQWGqgtW2PQNp/view?usp=sharing
Comments
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!
Fixed in iOS 15.0