I installed UICollectionView (with default layout and vertical scrolling) with custom cells loaded from xib. Cells contain a pair of elements (a UILabel and a UIView ) with restrictions on them. I set limits so that the cell height increases as the height of the label text increases using the new UICollectionViewFlowLayout property available in iOS8, estimatedItemSize :
layout.estimatedItemSize = CGSizeMake(self.collectionView.frame.width, 100)
Everything works like a charm, except for one big problem: UICollectionView loads only half of the elements returned by the numberOfItemsInSection method. So, when a method returns, say, 10, my UICollectionView displays only 5 cells (but displays and displays them perfectly).
Some results of my debugging attempts:
- I was able to force the remaining elements to be loaded by calling
invalidateLayout or changing the number of partitions from 1 to 2. But this is just debugging the hacks. - Separately, everything works like a charm when I replace the
estimatedItemSize itemSize property, i.e. hard-coded element size. But it defeats the self-separation functionality that I would like to implement.
I guess something is wrong with how I think about cells of the very size. In particular, I am wondering if the problem is related to limitations.
I would appreciate any help here.
ios ios8 swift uicollectionview uicollectionviewcell
rainypixels
source share