Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

didSelectItemAt not called in CustomCollectionVC ? #10

Open
ghost opened this issue Jul 9, 2019 · 2 comments
Open

didSelectItemAt not called in CustomCollectionVC ? #10

ghost opened this issue Jul 9, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jul 9, 2019

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

@ghost
Copy link
Author

ghost commented Jul 11, 2019

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)")
    }

@ghost
Copy link
Author

ghost commented Jul 11, 2019

This is also important fix for this library #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants