jjzjj

ios - UICollectionView cellForItemAtIndexPath 滚动后返回 nil

coder 2024-01-12 原文

我对 UICollectionView 有疑问。下面的代码是返回获取某个点的单元格(CGPoint)

CollectionViewCell* cell = (CollectionViewCell*) [mCollectionView cellForItemAtIndexPath:       [mCollectionView indexPathForItemAtPoint:point]];
if (cell)
     NSLog(@"Cell exists");
else
     NSLog(@"Cell doesn't exist");

如果 UICollectionView 保持不动,这将返回一个有效的单元格。如果向下滚动,则返回 nil。我不确定是什么问题。 UICollectionView 滚动效果很好。 collectionview 单元没有问题。

请问有人能帮帮我吗?

最佳答案

这不是问题,在 UICollectionView 和 UITableView 中,不可见的单元格将从内存中删除。

关于ios - UICollectionView cellForItemAtIndexPath 滚动后返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19660420/

有关ios - UICollectionView cellForItemAtIndexPath 滚动后返回 nil的更多相关文章

随机推荐