【发布时间】:2013-01-17 20:55:06
【问题描述】:
我正在构建一个类似于 iPhone 照片应用的应用。我可以使用PSUICollectionView 在网格状视图中显示图像。当我点击集合视图的网格单元格时,应该会出现一个复选框图像。我的问题是当我使用以下代码时,我看到多个随机单元格填充了复选框图像。
- (void)collectionView:(PSUICollectionView *)collectionView didSelectItemAtIndexPath: (NSIndexPath *)indexPath
{
NSLog(@"%@ - %d", NSStringFromSelector(_cmd), indexPath.item);
ImageGridCell *cell = (ImageGridCell *)[collectionView cellForItemAtIndexPath:indexPath];
UIButton *chkboxBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[chkboxBtn setFrame:CGRectMake(60, 60, 30, 30)];
[chkboxBtn setImage:[UIImage imageNamed:@"Checkmark-iPhone.png"] forState:UIControlStateNormal];
[cell addSubview:chkboxBtn];
}
【问题讨论】:
-
任何帮助将不胜感激。
标签: ios uicollectionview uicollectionviewcell