如何更改UICollectionViewCell选择不可见的单元格?

时间:2015-07-16 12:25:36

标签: ios swift uicollectionview uicollectionviewcell

有没有办法改变所选择的'不在" visibleCells"中的UICollectionViewCell的成员? (除了保存最后一个选定单元格的Cell对象...)

1 个答案:

答案 0 :(得分:1)

为了更改项目的选定状态,您应该调用方法selectItemAtIndexPath:可以重复使用项目,因此如果您调用UICollectionViewCell的setSelected方法,则可能无法选择正确的项目。

[self.collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone];

如果您想取消选择它,您可以使用以下方法:

[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];