无法使类型的视图出列:带标识符的UICollectionElementKindCell

Pau*_* T. 4 ios uicollectionview uicollectionviewcell uicollectionviewlayout

我有UICollectionView,但似乎我设置了一切正确.但我得到错误:

'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'
Run Code Online (Sandbox Code Playgroud)

我的故事:

在此输入图像描述

在此输入图像描述

在此输入图像描述

我的代码是:

@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);
}
Run Code Online (Sandbox Code Playgroud)

我试图[self.collectionViewMain registerClass:[PeopleCellForList class] forCellWithReuseIdentifier:@"PeopleCellForList"]viewDidLoad:(在此期间,我试图删除并不会删除故事板细胞),但没有帮助.

Mat*_*s R 17

你有一个额外的空间 @"PeopleCellForList "