Reputation: 7527
(Update below)
When I delete items from a section in my collection view (say, section 0), I find that the supplementary views (in this case headers from the UICollectionViewFlowLayout) pop into place as the cells from section zero animate away and a 'duplicate' of the latter sections animates in with them to match the ones that have popped in.
Naturally the ones that pop into place could be the 'duplicates' but it doesn't really matter. It's like the collection view can see the future! and then is catching up with itself. That's how the animation feels.
Do you know if there is some quirk or bug or easy fix to suppressing this extra popping supplementary view?
Update: I've noticed this also occurs with the cells, not just the sections, and it seems to 'double' the bottom few cells and sections on the screen. When I delete cells from the zero section, a handful of sections and cells below it animate properly without duplicates, but beyond a certain point, they pop. A constraints issue?
Upvotes: 2
Views: 1366
Reputation: 1710
This is a bug with UICollectionViewFlowLayout. For whatever reason UICollectionViewFlowLayout cannot properly animate cells that are not on screen.
I've done two workarounds that address the issue but none solve it completely. The first is to artificially increase the frame of the collection view so that it creates the cells needed for animation, and thusly animates correctly upon data change. This is a bit of a hack and doesn't work for all cases.
The other option is to write your own flow layout from scratch. This works for me and complexity is entirely up to how complex your layout is. Here is an example I used for writing my own flowlayout: https://github.com/chiahsien/UICollectionViewWaterfallLayout
Upvotes: 2