攻在UICollectionView单UICell时再滚动向下或向上的UICollectionView我看到更多的一个单元格,选择我有一个奇怪的问题。其他未被点击的单元格似乎是在整个UICollectionView布局中随机选择的。我在UICollectionView中有3列单元格和许多行。UICollectionView点击选择多个单元格
在我的代码,我有以下:
- (void)collectionView:(UICollectionView *)myCV didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
LogInfo(@"Item Selected");
// highlight the cell user tapped on
UICollectionViewCell *cell = [myCV cellForItemAtIndexPath:indexPath];
[cell.layer setBorderWidth:10.0f];
cell.layer.borderColor = [UIColor colorWithRed: 108/255. green: 166/255. blue: 16/255. alpha:1.0].CGColor;
cell.layer.CornerRadius = 10;
}
亮点代码只是把边框上的螺纹细胞。
有没有一种方法,以确保只有被点击单元格选择?
Jirune嗨。谢谢你的回复。“将选定的indexpath保存在某处。”你能解释一下我应该保存的位置吗? – motionpotion
Hmm.Just声明一个全局变量NSIndexPath,然后分配选定indexpath该变量,现在根据你刚才申请的打印格式在cellForItemAtIndexPath完蛋了存储索引.. – Jirune