I'm trying to get a UICollectionView working in my application and for some reason I keep getting a sigabrt. The error I am getting is
* Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:]
I have googled around, and it seems like most of the time this is related to the neglecting to registerClass forCellWithReuseIdentifier, but I am doing this as required in the view did load method. My code is as follows:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
[self.collectionView reloadData];
self.refreshControl = [[UIRefreshControl alloc]init];
[self.collectionView addSubview:self.refreshControl];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"Cell " forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
Does anyone know what I might be missing?