UICollectionViewDelegate not calledDeselectItemAtIndexPath



  • There is no one in the project. UITapGestureRecognizer♪ Multiple allocations allowed collectionView.allowsMultipleSelection = YESWhy method didDeselectItemAtIndexPath Is it only a matter of having a cell down? Is that what it is? For normal pressurization didSelectItemAtIndexPathEven if the cell is already set.

    - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
        [self.collectionView selectItemAtIndexPath:indexPath animated:YES scrollPosition:UICollectionViewScrollPositionNone];
        //работа с данными, вызов перезагрузки ячейки для обновления внешнего вида
        [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
    }
    
    • (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
      [self.collectionView deselectItemAtIndexPath:indexPath animated:YES];
      //работа с данными, вызов перезагрузки ячейки для обновления внешнего вида
      [self.collectionView reloadItemsAtIndexPaths:@[indexPath]];
      }


  • Try throwing out the cell (even if you can't see it) through this hack:

    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
        cell.selected = YES;
        [collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone];
        return cell;
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 1
  • 2
  • 2
  • 3
  • 2
  • 3
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2