Unpredictable sizing/positioning issues for UICollectionView cells that use self-sizing (iOS8, estimatedItemSize)
| Originator: | rainypixels | ||
| Number: | rdar://18787362 | Date Originated: | 27-Oct-2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | |
| Classification: | Reproducible: |
Summary: This sample attempts to recreate a tableview layout using UICollectionView by setting the flow layout to vertical, and registering a custom cell (CollectionViewCell.xib) with a label and some constraints. The flow layout initially uses a fixed itemSize equal to (screenWidth, 200). This produces a layout that’s closest to ideal with the one expected issue that cells whose intrinsic content height is less than 200pts leaves whitespace below the label. Tapping the left bar button toggles the flow layout to use an estimatedItemSize of (screenWidth, 200). This produces a layout where, while cells appear one below the other and determine correct heights, their widths and positions are incorrect and seemingly random. Tapping the left bar button again toggles the flow layout to use an estimatedItemSize of (screenWidth, 10). This produces the same width and positioning issues outlined in the prior paragraph. In addition, half of the cells don’t show up in the collection view. I assume they’re positioned off-screen. Steps to Reproduce: 1. Run sample app 2. Tap “UICV” right bar button to invoke a modal segue to the collection view 3. Scroll to bottom to verify 44 cells 4. Tap “itemSize (screenWidth, 200)” left bar button to reload collectionview with estimatedItemSize of (screenWidth, 200) 5. Scroll to examine sizing and positioning issues 6. Tap “estimatedItemSize (screenWidth, 200)” left bar button to reload collectionview with estimatedItemSize of (screenWidth, 10) 7. Scroll to examine sizing and positioning issues Expected Results: The two layouts that use estimatedItemSize should be identical to the first layout that uses a fixed itemSize with the exception that their heights should self-size. Actual Results: When the estimatedItemSize is (screenWidth, 200), cells have randomly incorrect widths and positions. When the estimatedItemSize is (screenWidth, 10), cells have randomly incorrect widths and positions, and half of the cells are not loaded. Version: iOS 8.1 (12B411) Notes: This app also serves as the sample app submitted along with currently open rdar://18698008. You can ignore the opening screen and the debugger output. Configuration: iOS 6 Simulator & iPhone 6 64GB (and iPhone 5S 32GB) AT&T Attachments: 'selfsizingcells.zip' was 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!