我正在構建類似iPhone照片應用程序的應用程序。我可以使用PSUICollectionView
在視圖中顯示圖像。當我點擊收集視圖的網格單元格時,應出現複選框圖像。我的問題是當我使用下面的代碼時,我看到多個隨機單元格正在填充複選框圖像。如何在uicollectionview中檢測單元格didselect委託方法
- (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];
}
任何幫助,將不勝感激。 –