Selecting a UICollectionViewCell will highlight UITableViewCells within it

Originator:brock
Number:rdar://16645887 Date Originated:2014.04.17
Status:Behaves correctly Resolved:
Product:iOS Product Version:7.1
Classification: Reproducible:Always
 
Summary:
Selecting a collection view cell will highlight table view cells in a table view that's inside the collection view cell.

Steps to Reproduce:
Click on the colored bar in the collection view cell to select the collection view cell.

Expected Results:
The collection view cell is selected, but the table view cells remain unselected and unhighlighted.

Actual Results:
The collection view cell is selected, and the table view cells become highlighted, but not selected.

The table view cells are not actually selected. setSelected: is never called on the table view cell, and indexPathsForSelectedRows on the table view itself returns an empty array. The cells are only highlighted, and indeed, setHighlighted: is called on the table view cells.

Version:
7.1 (11D167)

Notes:
Ultimately, the `setSelected:` method on the UICollectionViewCell seems to be the problem. If the cell subclass in use does NOT call that method on the superclass, this problem does not manifest itself. As such, I'm inclined to believe that the UICollectionViewCell implementation of `setSelected:` does something like a recursive walk through its subviews to set them selected and/or highlighted.

Workaround: set the table cells to use no selection style:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
This only masks the problem, and prevents selections from being used normally on the table view.

Faulty workaround: use collectionView:shouldHighlightItemAtIndexPath: on the UICollectionViewDelegate to return NO. This will prevent the collection view cell and table view cell from being highlighted, BUT it also prevents the collection view cell from being properly selected. When that method returns NO, collectionView:didSelectItemAtIndexPath: is never called. Separate bug.

Configuration:
Able to replicate this in iOS 7.1 in both the iOS Simulator and on an iPhone 5.

Sample project: https://github.com/brockboland/ExtraCellSelection

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!