I create a UICollectionView where some of the UICollectionViewCells contain a UITableView .
This works fine and everything is fine until I touch UICollectionViewCell somewhere else than UITableView . This invokes the setHighlighted method setHighlighted for all UITableViewCells in the table.
Below is a rough drawing of a UICollectionViewCell . UITableView only covers βcell oneβ to βcell threeβ. Clicking anywhere outside this table, but inside the UICollectionViewCell causes the selection of cells.
------------------------- | Title goes here | | | ------------------------- | | | Cell one | ------------------------- | | | Cell two | ------------------------- | | | Cell three | ------------------------- | Button outside table | |-----------------------|
The call stack looks something like this.
[MyTableViewCell setHighlighted:] [UICellHighlightingSupport highlightView:] UIApplicationMain main
It seems that the UICollectionViewCell redirects the selection command to all cells.
I worked on the problem by overloading the setHighlighted method in my subclass of UITableViewCell and not calling the super implementation. This seems a bit hacky, though, and I wonder if this behavior can be somehow avoided.
EDIT: I assume this behavior occurs when a UICollectionCellView setHighlighted is called for all of its children. I understand that this is useful in most other cases.
source share