title: How can a get the auto layout size of the UICollectionViewCells in iOS 8? (systemLayoutSizeFittingSize returns size with zero height in iOS 8)
body: <p>Since iOS 8 <code>[UIColletionViewCell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]</code> returns a size with height of 0. </p>
  
  <p><strong>Here's what the code does:</strong></p>
  
  <p>To determine the size for cell in a <code>UICollectionView</code> in iOS 7 I use <code>systemLayoutSizeFittingSize:</code> on a cell defined in a xib file using auto layout. The size depends on the font size of an <code>UILabel</code> being a subview of the <code>UICollectionViewCell</code> in my xib file. The label's font is set to <code>UIFontTextStyleBody</code>. So basically the cell's size depends on the font size setting made in iOS 7.  </p>
  
  <p><strong>Here is the code itself:</strong></p>
  
  <pre><code>+ (CGSize)cellSize {
      UINib *nib = [UINib nibWithNibName:NSStringFromClass([MyCollectionViewCell class]) bundle:nil];
  
      // Assumption: The XIB file only contains a single root UIView.
      UIView *rootView = [[nib instantiateWithOwner:nil options:nil] lastObject];
  
      if ([rootView isKindOfClass:[MyCollectionViewCell class]]) {
          MyCollectionViewCell *sampleCell = (MyCollectionViewCell*)rootView;
          sampleCell.label.text = @"foo"; // sample text without bar
  
          [sampleCell setNeedsLayout];
          [sampleCell layoutIfNeeded];
  
          return [sampleCell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
      }
  
      return CGSizeZero;
  
  }
  </code></pre>
  
  <p>It works perfectly fine in iOS 7 but not in iOS 8. Unfortunately I have no clue why.  </p>
  
  <h2><strong>How can I get the auto layout size of the UICollectionViewCells in iOS 8?</strong></h2>
  
  <p><strong>PS:</strong> Using </p>
  
  <pre><code> return [sampleCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code> return [sampleCell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
  </code></pre>
  
  <p>as somebody might suggest, doesn't make any difference. </p>