I have a UICollectionView that appropriately recognizes taps on its cells in its collectionView(didSelectItemAt: )
delegate method.
However, I then embedded a collection view within the cell itself (so that each cell has its own collection view inside of it), but now the parent cell is not recognizing any taps anymore, I’m assuming because the embedded collection view is eating them up.
Is there some property that needs to be set so that the original (parent) cells register taps again even with their embedded collection views?
2
Answers
This functionality can be confusing, as users are accustomed to "something else" happening when interacting with a control in a table view cell, rather than it selecting (or also selecting) the row itself.
However, if you really want to do that…
One approach is to use a closure in your cell. When you handle
didSelectItemAt
use the closure to tell the table view controller to select the row.Note that Apple’s docs point out:
So, if you need to execute code when a table view row is selected, you’ll need to call that yourself – something like this:
Using the code in my answer to your previous question…
In
SomeTableCell
add this closure setup:and, still in
SomeTableCell
:Next, in
cellForRowAt
in the table view controller, set the closure:you can implement UICollectionViewDataSource & UICollectionViewDelegate methods of inner collectionViews inside the cells itself & pass the events with closure to main class with main UICollectionView.