无法使类型的视图出列:带标识符的UICollectionElementKindCell [英] could not dequeue a view of kind: UICollectionElementKindCell with identifier
本文介绍了无法使类型的视图出列:带标识符的UICollectionElementKindCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有UICollectionView,但似乎我设置了一切正确。但是我收到错误:
I have UICollectionView, but it seems that I set up everything right. But I get the error:
'could not dequeue a view of kind: UICollectionElementKindCell with identifier PeopleCellForList - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
我的故事:
我的代码是:
@interface PeopleCellForList : UICollectionViewCell
@end
@implementation PeopleCellForList
@end
#pragma mark - UICollectionView Datasource
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
return self.arrayPeople.count;
}
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView {
return 1;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"PeopleCellForList " forIndexPath:indexPath];
return cell;
}
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
}
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
}
#pragma mark – UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGFloat width = 106;
CGFloat height = width;
if (indexPath.row % 3 == 2) {
width = 108;
}
return CGSizeMake(width, height);
}
- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(0, 0, 0, 0);
}
我试过 [self.collectionViewMain registerClass:[PeopleCellForList class] forCellWithReuseIdentifier:@PeopleCellForList]
in viewDidLoad:
(在此期间我试图删除而不是从故事板中删除单元格),但那并没有没帮忙。
I tried [self.collectionViewMain registerClass:[PeopleCellForList class] forCellWithReuseIdentifier:@"PeopleCellForList"]
in viewDidLoad:
(during that I tried to remove and not remove cell from storyboard), but that didn't help.
推荐答案
你在 @PeopleCellForList$ c $中有一个额外的空间c>
这篇关于无法使类型的视图出列:带标识符的UICollectionElementKindCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文