UICollectionView同时选择多个单元格

时间:2013-12-05 09:48:15

标签: iphone uicollectionview uicollectionviewcell

我有一个UICollectionView和一个UICollectionViewCell作为子类,在此单元格中我有按钮和标签从XiB创建,当我点击单元格中的任何UIButton 我正在更改该单元格中UILabel的BG图像,然后我滚动UICollectionViewCell 我看到其他单元格发生同样的事情。我该如何解决这个问题???

这就是我如何调用自定义类..

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

     NSString *identifier = @"Cell";

     NMCFAIPadWishListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
[cell setWishList:[[self wishListData] objectAtIndex:[indexPath row]] delegate:self];

     return cell;

}

1 个答案:

答案 0 :(得分:0)

试试这段代码告诉我它的工作与否

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

    NMCFAIPadWishListCell *cell = (NMCFAIPadWishListCell*)[collectionView cellForItemAtIndexPath:indexPath];
    [cell.imageCategory.image:[UIImage imageNamed:@"selectedeimagename.png"]
 ];
}
-(void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NMCFAIPadWishListCell *cell = (NMCFAIPadWishListCell*)[collectionView cellForItemAtIndexPath:indexPath];
[cell.imageCategory.image:[UIImage imageNamed:@"deselectedeimagename.png"]
 ];

}