Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UICollectionView self-sizing-cell on iOS 8 will crash with UIDynamic flowLayout and repeating call to _updateVisibleCellsNow

I am trying to use the so called "self sizing cell" which means:

  • set estimatedItemSize on flowLayout
  • overide preferredLayoutAttributesFittingAttributes in cell class

Such as this: UICollectionView Self Sizing Cells with Auto Layout

And I need dynamic effect like this:http://www.teehanlax.com/blog/implementing-a-bouncy-uicollectionviewlayout-with-uikit-dynamics/

It works fine without UIDynamic, but I need UIDynamic. As what I see, it will call the prepareLayout and layoutAttributesForElementsInRect until die, there will be too many _updateVisibleCellsNow waiting in line.

I have no idea how to solve that, please help me in case u see. Or, if I am using those technologies in wrong way, please let me know.

like image 957
iaomw Avatar asked Jun 24 '15 11:06

iaomw


1 Answers

Two things worked for me:

  • Make sure your collection view itself has layout constraints defined for placement within its superview.
  • I got this crash when the estimated size was larger than the final size. If I set the estimated size to a smaller value the crash stopped.
like image 153
Chris Garrett Avatar answered Oct 14 '22 15:10

Chris Garrett