Biorąc pierwszy zanurzyć z widokiem zbiórki i używam do tego błędu:błąd nie mógł dequeue widok rodzaju UICollectionElementKindCell
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
Kod jest bardzo prosty, jak pokazano poniżej. Nie mogę do końca życia zrozumieć, czego mi brakuje.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
Kolekcja widok kontroler został stworzony za pomocą stalówki i delegatów & datasources są ustawione na właściciela pliku.
Zobacz plik nagłówka sterownika również jest naprawdę podstawowy.
@interface NewMobialViewController_3 : UICollectionViewController <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@end
[self.collectionView registerClass: [UICollectionViewCell class] forCellWithReuseIdentifier: @ "Cell"]; –