UICollectiveViewCell 中的 UIView 无法隐藏

UIView in UICollectiveViewCell can't hidden

我得到了一个以编程方式创建的 UICollectionView。我希望集合视图按以下方向运行:

  1. 用户触摸单元格
  2. 隐藏覆盖图像的 uiview
  3. 用户再次触摸单元格
  4. 显示 uiview 覆盖图像

1.) 在用户触摸单元格中的图像之前,它看起来像这样

http://upload.siamza.com/1811355

2.) 用户触摸单元格中的图像后,它将看起来像这样

http://upload.siamza.com/1811359

3.) 如果用户再次触摸图像,它将看起来像 1.)

现在我的 select 和 deselect 是这样的:

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if(collectionView == genrescollectView){

    genresRecCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"genresRecCell" forIndexPath:indexPath];

        cell.checkforselectView.hidden = FALSE;

    }
}

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

     genresRecCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"genresRecCell" forIndexPath:indexPath];
        cell.checkforselectView.hidden = TRUE;

    }
}

但它似乎无法在

工作

cell.checkforselectView.hidden = 假;

cell.checkforselectView.hidden = 真;

我已检查 cellForItemAtIndexPath 是否工作,方法是添加 cell.checkforselectView.hidden = 假;

它有效,所以我想知道任何人都可以帮助我解决这个问题,现在在 cellForItemAtIndexPath

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

        genresRecCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"genresRecCell" forIndexPath:indexPath];
        NSString *imageGenres = [genresData objectAtIndex:indexPath.row];
        cell.genresImage.image = [UIImage imageNamed:imageGenres];
        NSString *textToParse = imageGenres;
        NSArray *components = [textToParse componentsSeparatedByString:@"."];
        NSString *genresText = [components firstObject];
        cell.labelGenres.text = genresText;
        cell.genresImage.layer.cornerRadius = 10.0f;
        cell.genresImage.layer.masksToBounds = YES;

        //---------> this is where I check whether it work or not(and it work).
        cell.checkforselectView.hidden = FALSE;

        return cell;

}

提前致谢:)

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

使用

[collectionView cellForItemAtIndexPath:indexPath]

而不是将新单元格出列