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];
}