UICollectionView Self Sizing Cells with Auto Layout

前端 未结 16 2018
野性不改
野性不改 2020-11-22 05:58

I\'m trying to get self sizing UICollectionViewCells working with Auto Layout, but I can\'t seem to get the cells to size themselves to the content. I\'m having

16条回答
  •  眼角桃花
    2020-11-22 06:12

    To whomever it may help,

    I had that nasty crash if estimatedItemSize was set. Even if I returned 0 in numberOfItemsInSection. Therefore, the cells themselves and their auto-layout were not the cause of the crash... The collectionView just crashed, even when empty, just because estimatedItemSize was set for self-sizing.

    In my case I reorganized my project, from a controller containing a collectionView to a collectionViewController, and it worked.

    Go figure.

提交回复
热议问题