我有一个 UICollectionView 用于显示数组的元素,但是当我滚动它时,行号会跳来跳去indexPath
并且不显示正确的内容。要调试,我只需让单元格显示行号:
- (UICollectionViewCell*) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CNArticleCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier: ArticleCellIdentifier forIndexPath: indexPath];
// check if there's anything here
if ([CNArticleManager shared].loadedArticles.count < 1)
return cell;
// get current article
MWFeedItem* item = [[CNArticleManager shared].loadedArticles objectAtIndex: indexPath.row];
cell.item = item;
cell.title = [NSString stringWithFormat: @"%i", indexPath.row];
cell.backgroundColor = [UIColor greenColor];
return cell;
}
这就是它所显示的。左边被切断了一点,但那是一个 4,然后是一个 1...我不明白为什么大多数单元格都是空白的,或者为什么出现的单元格是无序的,或者(未显示这里)为什么有些标题相互重叠。