gpt4 book ai didi

dequeueReusableCellWithReuseIdentifier 上的 iOS SIGABRT

转载 作者:行者123 更新时间:2023-11-29 10:59:03 25 4
gpt4 key购买 nike

<分区>

我正在尝试让 UICollectionView 在我的应用程序中工作,但出于某种原因,我不断收到 sigabrt。我得到的错误是

* -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:] 断言失败

我用谷歌搜索了一下,似乎大多数时候这与忽略 registerClass forCellWithReuseIdentifier 有关,但我是按照 View did 加载方法中的要求执行此操作的。我的代码如下:

 - (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;
}

有谁知道我可能遗漏了什么?

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