Incorrect size returned from systemLayoutSizeFittingSize: for UICollectionViewCells in iOS 8

Originator:rowun
Number:rdar://18061720 Date Originated:19-Aug-2014 02:15 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6-Beta5 (6A279r)
Classification:Serious Bug Reproducible:Always
 
This is a duplicate of rdar://18047251

This is a duplicate of rdar://17958382

Summary:
Calling systemLayoutSizeFittingSize on a UICollectionViewCell that has layout constraints that define a valid height returns 0 for the height. The same layout works work fine for regular UIViews and also works fine in iOS 7.

Steps to Reproduce:
Load a cell from a nib with constraints set to define the size of the cell. Notice that any call to systemLayoutSizeFittingSize: returns CGSizeZero.

Expected Results:
systemLayoutSizeFittingSize: should return a proper size.

Actual Results:
systemLayoutSizeFittingSize returns a height of 0.

Comments

workaround with systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:

For what it's worth, you can currently work around this by calling systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:

For instance:

  CGSize constrainedSize;
  if ([self.sizingCommentCell respondsToSelector:@selector(systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:)]) {
    constrainedSize = [self.sizingCommentCell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize
                                            withHorizontalFittingPriority:UILayoutPriorityRequired
                                                  verticalFittingPriority:UILayoutPriorityDefaultLow];
  }
  else {
    constrainedSize = [self.sizingCommentCell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
  }
By alexisgallagher at Aug. 20, 2014, 8 p.m. (reply...)

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!