UICollectionView - didDeselectItemAtIndexPath not called if cell is selected

后端 未结 7 1575
面向向阳花
面向向阳花 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:56

    Reloading the cell was solution for me. What i need was changing image in cell for a brief moment. I assign image to imageView in cellForItemAtIndexPath and when user touches the cell i change image and run mycode then reload the cell.

     func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
            let cell = collectionView.cellForItemAtIndexPath(indexPath) as! MenuCollectionViewCell
            cell.backgroundImageView.image = UIImage(named: "selected")
            // handle tap events
            collectionView.reloadItemsAtIndexPaths([indexPath])
        }
    

    Hope it helps someone.

    0 讨论(0)
提交回复
热议问题