UICollectionView Headers pinned to top jump around when items are added to collection view during a bounce animation/drag
| Originator: | openradar | ||
| Number: | rdar://29799459 | Date Originated: | 23/12/2016 |
| Status: | Open | Resolved: | |
| Product: | iOS + SDK | Product Version: | 9.3 + 10.2 |
| Classification: | Reproducible: | Always |
Summary: In a `UICollectionView` with * simple cells * a header * using a `UICollectionViewFlowLayout` * with its `sectionHeadersPinToVisibleBounds` set to `YES`, when items are added to a `UICollectionView` using `insertItemsAtIndexPaths` (inside a `performBatchUpdates` block) while the collectionview bounces (no matter whether it bounces back after the user let go or the user is still dragging the collectionView around), the header will move (partially) together with the bounce effect instead of sticking to the top. If items are added during scrolling but the collectionView is not bouncing the header sticks to the top as expected. If no items are added the header even sticks to the top during bouncing at the bottom edge of the collectionView, as expected. Steps to Reproduce: Use the attached example project, start the app and scroll to the bottom quickly and keep trying to scroll (which will make the collectionView bounce). Setting `collectionView.bounces = NO` will make the issue disappear. Attached you will also find a video showing the effect. Expected Results: Header stays sticky at the top all the time even when the bottom of the list is reached and the collectionView bounces. Note that the bouncing of the header when reaching the *top* is expected and perfectly fine. Actual Results: Header jumps around together with the movement of the bounce effect at the bottom Version: iOS 9.3 and 10.2 Notes: The example project contains a collection view controller that simulates paged loading of a list that will load additional items when the end of the list is close. We simulate the loading by adding items a short time later using dispatch_after. This "load more"-use case is how we found the bug and why it is annoying. Note that all the work (even the dispatched one) is performed on the main thread to avoid any issues due to multi-threading. You can easily modify both the batch size of items to be added as well as the delay in the example project but the provided configuration is one that we found to realistically simulate loading additional items over the network and makes it easy to reproduce the issue by scrolling fast. Configuration: any simulator or device
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!