UICollectionViewFlowLayout doesn't resize cells with an UIView inside

Originator:s
Number:rdar://19292817 Date Originated:2014-12-18
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification:Other bug Reproducible:Always
 
Summary:
When using auto resizing cells with auto layout and UICollectionViewFlowLayout on cells with an UIView inside, the layout behaves really weird and doesn't resize the cells to the correct size.

The problem I had was that I wanted to use a variable height but max width on my cells, so I thought, well maybe I could put another view in the contentView to which I can add a max width constraint. However, doing so, the layout started to behave all weird and then crash after scrolling up and down a few times.

The attached project mimics the collection view that was used in the WWDC session about the news in table views and collection views. It has a collection view with words in every cell.

I've provided a working copy and the non-working one. Just change the cell identifier to this:
"with view" - the non-working one
"without view" - the working one

But why don't I stick with the working cell? Well, most of the time you'd want more content than just a single label, that's when I added the other view to sort of resize the contentView with a fixed width and varying height. The point of doing this is that I don't want to add width constraints to the contentView since it's resizingMasks removes then.

Steps to Reproduce:
1. Build and run the attaches project
2. Scroll up and down and memorize really how it should look (since it'll default on the working cells)
3. Change the cell identifier to "with view"
4. Run the second time, everything should now look weird. The labels are getting cut.

Expected Results:
Both cells with or without the view should behave in the same way

Actual Results:
Well, they don't. And the layout is crashing whilst scrolling up and down a few times.

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!