-[UICollectionView cellForItemAtIndexPath:] doesn't return every cell
| Originator: | michaelhochs | ||
| Number: | rdar://29000276 | Date Originated: | 28-Oct-2016 02:44 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 10.1 |
| Classification: | Other Bug | Reproducible: | Always |
Summary: When asking a collection view for cellForItemAtIndexPath: it does only return cells that are visible and not all cells that are configured. This was fine before cell prefetching became a thing, as these two states basically were identical. Now however this is different. Steps to Reproduce: - Open the sample app - Scroll through the list and notice the different cell colors - Red means `cellForItemAtIndexPath:` did not return the cell, blue means it did. Expected Results: - All cells are blue Actual Results: - Depending on scroll speed, most of the non-initial cells are red. Regression: Notes: This is because in the collectionView:cellForItemAtIndexPath: delegate call I dispatch a configuration event. From what I’ve experienced, this is a pretty common approach to load data asynchronously. The issue arises when that data loads faster than the cell scrolls into the view. I am aware of the fact that the documentation says `Returns the visible cell object at the specified index path.`, however to me this sounds like a bug. As mentioned above: Previously this was identical with everything that was configured via `collectionView:cellForItemAtIndexPath:` and due to the equal naming of these two methods they really should work hand in hand. So now that prefetching is a thing, the documentation and functionality on this should be changed to make these methods work like counterparts. `cellForItemAtIndexPath:` should return all cells that have been configured by `collectionView:cellForItemAtIndexPath:`.
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!
Example: https://github.com/PSPDFKit-labs/radar.apple.com/tree/master/29000276%20-%20CellForItemAtIndexPath%20doesnt%20contain%20all%20cells