Ios UICollectionView在快速滚动后不显示单元格

Ios UICollectionView在快速滚动后不显示单元格,ios,uicollectionview,uicollectionviewcell,uicollectionviewlayout,Ios,Uicollectionview,Uicollectionviewcell,Uicollectionviewlayout,我有一个UICollectionView,当在某些情况下滚动时,它会停止更新单元格。 它加载了一些单元格,但当我向下或向上滚动时,UIcollectionView的其余部分是空的,尽管contensize的大小大于可见的几个单元格的大小 当我快速滚动时,会发生更多的情况,随机cellForItemAtIndexPath停止被调用,UICollectionView只显示最后加载的单元格,其余空间为空 这是我的密码: [self.collectionView registerNib:[UINib n

我有一个UICollectionView,当在某些情况下滚动时,它会停止更新单元格。 它加载了一些单元格,但当我向下或向上滚动时,UIcollectionView的其余部分是空的,尽管contensize的大小大于可见的几个单元格的大小

当我快速滚动时,会发生更多的情况,随机cellForItemAtIndexPath停止被调用,UICollectionView只显示最后加载的单元格,其余空间为空

这是我的密码:

[self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([NewsCollectionViewCell class]) bundle:nil] forCellWithReuseIdentifier:NSStringFromClass([NewsCollectionViewCell class])];

[self.collectionView registerClass:[NewsHeaderCollectionReusableView class]  forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass([NewsHeaderCollectionReusableView class])];
pragma标记UICollectionViewDataSource pragma标记UICollectionViewDelegate pragma标记UICollectionViewDelegateFlowLayout
您是否通过在单元格中指定唯一颜色进行检查?因为单元格数据中的某些时间问题是的,仅显示背景颜色而不显示数据的单元格具有相同的问题这很好,因此您只需检查数据中是否有未显示正确数据的单元格,问题将解决这不是数据。滚动一段时间后,cellForItemAtIndexPath将停止调用,并且只有在此之前屏幕中的单元格才可见。当滚动查看uicollectionview时,仅显示这些单元格,其余单元格将丢失。@principeroxido您找到问题的解决方案了吗?我也有同样的问题。
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView
 numberOfItemsInSection:(NSInteger)section
{
return self.newsArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
              cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NewsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([NewsCollectionViewCell class]) forIndexPath:indexPath];

[cell refreshWithContentModel:self.newsArray[indexPath.item]];

return cell;
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
       viewForSupplementaryElementOfKind:(NSString *)kind
                             atIndexPath:(NSIndexPath *)indexPath
{
NewsHeaderCollectionReusableView *collectionReusableView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:NSStringFromClass([NewsHeaderCollectionReusableView class]) forIndexPath:indexPath];

if (self.newsArray.count) {
    [collectionReusableView refreshWithContentModel:self.newsArray[0]];
}

return collectionReusableView;
}
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.item == self.newsArray.count - 1) {
    [self addMoreNews]; // add items to array and call collection reloaddata
}
}
- (CGSize)collectionView:(UICollectionView *)collectionView
              layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{    
return CGSizeMake(ceilf(self.collectionView.bounds.size.width / 3.0) - 10, ceilf(self.collectionView.bounds.size.height / 3.0));
}

- (CGSize)collectionView:(UICollectionView *)collectionView
              layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{

return CGSizeMake(self.collectionView.bounds.size.width, ceilf(self.collectionView.bounds.size.height / 2.0));
}