Fogmeister Fogmeister - 2 years ago 422
iOS Question

iOS Assertion Failure in UICollectionView

I'm getting the error ...

*** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-2372/UICollectionView.m:2249

When trying to display a UICollectionView.

The lines causing it are...

static NSString *CellIdentifier = @"Cell";

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];

Error happening on the dequeue.

There are no other errors so I'm struggling to know where to begin with this.

Can anyone shed light on this?

Answer Source

Been reading the docs (should possibly have done this first :) )

Anyway, the collectionView I am using is within a separate xib file (not a storyboard) and from the docs...

Important: You must register a class or nib file using the
registerClass:forCellWithReuseIdentifier: or
registerNib:forCellWithReuseIdentifier: method before calling this method.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download