UICollectionView - didDeselectItemAtIndexPath not called if cell is selected

后端 未结 7 1599
面向向阳花
面向向阳花 2020-12-01 09:12

The first thing I do is to set the cell selected.

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndex         


        
7条回答
  •  抹茶落季
    2020-12-01 09:42

    In my case it was caused by using same logic for

    func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool
    

    as for

    func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool
    

    And when cell was selected shouldHighlightItemAt was returning false - and this prevented me to deselect that cell.

    Hope this will save someone's time :)

提交回复
热议问题