gpt4 book ai didi

ios - 无法使 : UICollectionElementKindCell with identifier 类型的 View 出列

转载 作者:可可西里 更新时间:2023-11-01 05:01:40 25 4
gpt4 key购买 nike

我有 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'

我的故事情节:

enter image description here

enter image description here

enter image description here

我的代码是:

@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);
}

我在 viewDidLoad: 中尝试了 [self.collectionViewMain registerClass:[PeopleCellForList class] forCellWithReuseIdentifier:@"PeopleCellForList"](在此期间我尝试删除而不是删除单元格来自 Storyboard),但这没有帮助。

最佳答案

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

关于ios - 无法使 : UICollectionElementKindCell with identifier 类型的 View 出列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23148918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com