UICollectionView crashes when invalidating non existing header
Originator: | steipete | ||
Number: | rdar://25873723 | Date Originated: | 22-Apr-2016 10:50 AM |
Status: | Open | Resolved: | |
Product: | iOS SDK | Product Version: | 9.3.1 |
Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
This is a duplicate of rdar://25873296 Summary: When implementing a custom `UICollectionViewLayout` subclass, invalidating a header index path that previously had no header and will have no header afterwards crashes. Steps to Reproduce: 0. Open the attached sample project 1. Run the project 2. Rotate the device Expected Results: Nothing happens Actual Results: App crashes Regression: Notes: The reason for the crash is in ViewController.m:46 (I’ve simply implemented the custom layout there). The call to `invalidateSupplementaryElementsOfKind:atIndexPaths:` makes the collection view throw an exception when validating the layout. I am aware of the fact that it may not be a good idea to invalidate stuff that has never been layouted, however I think the collection view should either handle this gracefully or at least provide a better exception message. Something similar to the well known UITableView messages, like ‘Due to invalidation a change in the header supplementary view in index path 0-0 was expected but the attributes before the update have been nil and the attributes after the update are nil’. The problem with that crash is that it can easily happen when integrating a layout that always has a header except for when the collection view is empty. Open Source Sample Code: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/25873296%20-%20EmptyCollectionViewLayoutCrashes
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!