I have a UICollectionViewCell
subclass, which displays only a UIView
subview with a background color right now, to show that it's there.
In order to load from the XIB, I have to replace this:
- (void)viewDidLoad {
[super viewDidLoad];
[self.localPlayerItemsView registerClass:[MBTradeCollectionViewCell class]
forCellWithReuseIdentifier:CellIdentifier];
}
with this:
- (void)viewDidLoad {
[super viewDidLoad];
UINib *nib = [UINib nibWithNibName:@"MBTradeCollectionViewCell" bundle:nil];
[self.localPlayerItemsView registerNib:nib forCellWithReuseIdentifier:CellIdentifier];
}
Upon doing that, I then get a crash on the first line in collectionView:cellForItemAtIndexPath:
:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MBTradeCollectionViewCell *aCell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier
forIndexPath:indexPath];
return aCell;
}
Here's the crash:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSObject 0x7d461780> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key itemCountView.'
It doesn't cause this crash when using registerClass:forCellWithReuseIdentifier:
, but then it doesn't load my xib.