UICollectionViewLayout not respecting element attributes z-index

Originator:matt
Number:rdar://27519174 Date Originated:25/7/16
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 10.0
Classification: Reproducible:Always
 
Summary:
We’ve got a custom UICollectionViewFlowLayout subclass that consists of a number of decoration views as “section” backgrounds, interactive supplementary views that act as tappable headers to expand/collapse sections, and obviously cells, which are arranged in a section in a simple grid flow layout. In iOS 8 and 9 this layout has worked perfectly, but using it on iOS 10, we noticed that cells were missing. In debugging this problem we’ve found that it appears that in iOS 10 the UICollectionViewLayoutAttributes zIndex property isn’t being properly obeyed, and some cells, and supplementary views (headers) are being presented behind our decoration view backgrounds.

Setting the section decoration view background to translucent shows the cells happily placed underneath. Also, inspecting the views in with the View Hierarchy debugger, shows the cells on the stack, but not in the proper hierarchy.

Steps to Reproduce:
1. Implement UICollectionViewFlowLayout which lays out a single decoration view for each section, supplementary view for each section, and multiple cells.
2. Provide a zIndex value of -1 (or 0) to the decoration view attributes in layoutAttributesForDecorationViewOfKind.
3. Provide a zIndex value of 10 to the cell attributes in layoutAttributesForItemAtIndexPath.
4. Provide a zIndex value of 20 to the section header (supplementary view) attributes in layoutAttributesForSupplementaryViewOfKind.
5. While running, if the layout is invalidated/reloaded, cells/supplementary views will randomly appear behind the decoration view, even though elements of both kinds have a higher int value for zIndex


Expected Results:
When the layout is invalidated/reloaded, cells and supplementary/decoration views are presented top to bottom layout order obeys the statement of “Items with higher index values appear on top of items with lower values.” as described in the UICollectionViewLayoutAttributes documentation.


Actual Results:
When the layout is invalidated/reloaded, cells/supplementary views will randomly appear behind the decoration view, even though elements of both kinds have a higher int value for zIndex.

Version:
iOS 10.0 (14A5309d)

Notes:
Attached are two screenshots captured *during* the expand/collapse (ie. add/delete of section items) animations, showing cells being presented under the decoration view background.

Configuration:
iPhone 6s / iPad Air 2, iOS Sim

Attachments:
'section-expand.png' and 'section-collapsed.png' were successfully uploaded.

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!