UICollectionView Flow Layout incorrectly lays out cells
| Originator: | buchanan.paul | ||
| Number: | rdar://32517782 | Date Originated: | June 1 2017 |
| Status: | Open | Resolved: | |
| Product: | UIKit | Product Version: | iOS 10.3.2 |
| Classification: | Reproducible: | Always |
When there are two sizes of cells in a UICollectionViewFlow layout a smaller cell that fits multiples in a row and a larger cell that only fits a single cell in a row, the smaller cells get incorrect horizontal placement on screen. Sample App: https://github.com/paulBuchanan/CollectionViewFlowLayoutBug The sample application shows the following scenarios when run on an 9.7" iPad, with the wide cell toggled on (button at bottom) Portrait orientation 1) (Section 0, 2, 4) Odd number of small cells in a section, one wide. The last small cell gets incorrectly horizontally centered. Landscape orientation 1) (Section 0) Single small cell in row, one wide cell. The small cell gets incorrectly horizontally centered. 2) (Section 1, 4) Two small cells in row, one wide cell. The second small cell is shifted over to the right leaving a gap. Steps to Reproduce: Run the attached sample application on an iPad 9.7" simulator like iPad Air 2. Do the following to see the various incorrect layout scenarios: Portrait orientation 1) (Section 0, 2, 4) Odd number of small cells in a section, one wide. The last small cell gets incorrectly horizontally centered. View the sample app in portrait orientation, scroll to one of the affected sections. Notice that the cells are left justified. Now press the 'Toggle wide cell' button at the bottom. Note that when the wide cell is added, the last small cell is horizontally centered. Landscape orientation 1) (Section 0) Single small cell in row, one wide cell. The small cell gets incorrectly horizontally centered. View the sample app in landscape orientation, scroll to section 0. Notice that the small cell is left justified. Now press the 'Toggle wide cell' button at the bottom. Note that when the wide cell is added, the small cell is horizontally centered. 2) (Section 1, 4) Two small cells in row, one wide cell. The second small cell is shifted over to the right leaving a gap. View the sample app in landscape orientation, scroll to section 1 or 4. Notice that the small cells are left justified. Now press the 'Toggle wide cell' button at the bottom. Note that when the wide cell is added, a gap in the cell layout exists between the last small cell and the preceeding small cell. Expected Results: Expected results is that cells are left justified, even when mix of cell sizes exist, and not gaps in layout are present. Observed Results: Smaller cells are horizontally centered, or gaps are left in layout. Version: iOS 10.3.2
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!