Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView AutoSizingCells weird jump/glitch on reloadData()

I'm using UICollectionView with the AutoSizingCells feature.

Issue 1 When I use this method in conjunction with estimatedItemSize and try to call reloadData(), I can observe, how the cell's content is changed.

I.e. if I had two cells:

Cell1 - "Text1"
Cell2 - "AnotherCell"

For a second I can see this state:

Cell1 - "AnotherCell"
Cell2 - "Text1"

And then, it updates to the correct one:

Cell1 - "Updated Text"
Cell2 - "AnotherCell"

Video: ReloadData

Issue 2

When I try to reload only the selected cell, I see another bug: the whole collectionView jumps and quickly updates its size.

Video: Reload Single Item

When not using AutoSizingCells at all, there are no issues with the cell reload.

The bug is reproducible even if I don't override preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes.

Is there any option to disable the animation with the AutoSizingCells enabled?

like image 700
Richard Topchii Avatar asked Dec 01 '25 06:12

Richard Topchii


1 Answers

I had similar issues with weird jump/glitch on reloadData().

The issue was fixed when I migrated my collection view to iOS 13 and new APIs:

  • Compositional Layout
  • Diffable Data Sources

You can find sample code here: https://stackoverflow.com/a/51231881/1136128

like image 156
boro Avatar answered Dec 03 '25 18:12

boro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!