UICollectionView only calling didSelectItemAtIndexPath if user double taps, will not call when user single taps

前端 未结 14 1643
名媛妹妹
名媛妹妹 2020-12-07 18:58

I have a UICollectionView which is about the size of the screen. The UICollectionViewCells that it displays are the same size as the collectionView. Each cell has a UIImage

14条回答
  •  太阳男子
    2020-12-07 19:16

    I ran into this problem in Swift 3 and xcode 8 , I had a view and a collection view inside this.The collection view has userInteractionEnabled to true , still it was not working.Fixed this issue by overriding shouldHighlightItemAt , I dont have any extra / custom implementation in this method , so i did not override this method.After adding the below code the didSelectItem method is called.

    func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
            return true
        }
    

提交回复
热议问题