This is a simple question that I thought would have an easy-to-find answer but didn’t. I want to select a cell in a collectionview. The main problem is that I can’t attach a gesture recognizer to a prototype cell. I want to grab the text from a label on the cell that is touched. I use the name in a different function in my view.
Or a simpler question: Is there a tutorial on tap selection from a list of items?
You have the method
collectionView:didSelectItemAtIndexPath:in the delegate. This should fire when you collect the cell and give you the correct indexPath for that particular cell.Use this indexPath in combination with the collectionView’s
cellForItemAtIndexPath:to access a particular cell.Example:
And, as long as I’m here. Swift-version: