2016-07-12 8 views
0

私はUICollectionViewを使用しています。ユーザーがセルをタップするとチェックボックスを表示したいので、マルチ選択も有効にしています。 私はdidSelectItemAtIndexPathからImageViewの非表示を解除しようとしたが、私は1つのセルをクリックして適切に画像をUICollectionViewセルに設定する

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    cell.checkBox.hidden = NO; 
    cell.checkBox.image = [UIImage imageNamed:@"check"]; 
} 

働いていないとImageViewのは、いくつかの他のセルに表示されます。 しかし、同じタップでは、NSArrayにimagenameを追加していて、その項目が正しく追加されています。

+0

次試してみることができます;' 'どこからcell'が来ていますか? – Larme

答えて

1

あなたは `cell.checkBox.hidden = NO

- (void)collectionView:(UICollectionView *)collectionViewdidSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewCell* cell = [collectionView cellForItemAtIndexPath:indexPath]; //typecast the cell to your custom cell 
    cell.checkBox.hidden = NO; 
    cell.checkBox.image = [UIImage imageNamed:@"check"]; 
} 
関連する問題