didSelectItemAt not called in CustomCollectionVC ?
Hello,
I noticed that function
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { }
Is not called when using CustomCollectionVC from example, it works fine for MyPinterestVC.
https://github.com/karek314/PinterestLayout/commit/4e2994664103319d8c4503e567b0152d13b71a9b https://github.com/karek314/PinterestLayout/commit/66c73eb8f9564512789c0333095a64d57139a9c3
Cheers
I noticed that ImageView of collectionview prototype has interactions disabled in interface builder, however it does not fix didSelectItemAt method. Solution for me was to add following code along with enabling interactions. Not perfect but it works just fine.
Viewdidload
let TapDetector: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(Tapped(_:)))
TapDetector.numberOfTapsRequired = 1
TapDetector.numberOfTouchesRequired = 1
collectionView?.addGestureRecognizer(TapDetector)
}
@objc func Tapped(_ tap: UITapGestureRecognizer){
let point: CGPoint = tap.location(in: collectionView)
let indexPath: IndexPath = (collectionView?.indexPathForItem(at: point))!
let ArrayIndex = indexPath.row
NSLog("Tapped: \(ArrayIndex)")
}
This is also important fix for this library https://github.com/MagicLab-team/PinterestLayout/pull/4