Note that there are some explanatory texts on larger screens.

plurals
  1. POCrash when trying to add section footer to UICollectionView
    primarykey
    data
    text
    <p>I'm trying to add a section footer to a UICollectionView and failing in a way I don't understand.</p> <p>I'm setting up the main cell like this:</p> <pre><code>[collectionView registerClass:[PickerOpenCell class] forCellWithReuseIdentifier:cellIdentifier]; UINib *cellNib = [UINib nibWithNibName:@"PickerOpenCell" bundle:nil]; [collectionView registerNib:cellNib forCellWithReuseIdentifier:cellIdentifier]; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; flowLayout.itemSize = CGSizeMake(130, 50); [collectionView setCollectionViewLayout:flowLayout]; </code></pre> <p>The xib is a subclass of UICollectionViewCell, and just contains a UILabel. This all works fine.</p> <p>Now I want to add the section footer, so I add this (interleaved with the code above, so the setCollectionViewLayout call is still the last one in the sequence):</p> <pre><code>[collectionView registerClass:[PickerOpenFooter class] forCellWithReuseIdentifier:footerIdentifier]; UINib *footerNib = [UINib nibWithNibName:@"PickerOpenFooter" bundle:nil]; [collectionView registerNib:footerNib forSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:footerIdentifier]; flowLayout.footerReferenceSize = CGSizeMake(130, 2); </code></pre> <p>The xib this time is a subclass of UICollectionReusableView, and contains a view (it's meant to be a horizontal white line between sections). The view's size is 130 x 2.</p> <p>The moment I add the footerReferenceSize line, the app crashes on the setCollectionViewLayoutLine with</p> <p>Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'</p> <p>I have no clue which array this might be, and Google is providing no help. Any ideas? I must have forgotten to hook something up, but I can't find it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload