collectionViewContentSize in iOS 10 using self-sizing cells
<p>Prior to iOS 10, I had a self-sizing table view that solely consisted of a UICollectionView with self-sizing cells using a standard UICollectionViewFlowLayout.  The collection view cells are sized using auto-layout.  In order for the table cell to size itself correctly, I had to find the collection view's content size and use that within the table cell's systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:.</p>

<p>I also found that the call to collectionView.collectionViewLayout.collectionViewContentSize used the estimatedItemSize instead of the correctly sized cell sizes unless I called collectionView layoutIfNeeded.  This resulted in a systemLayoutSizeFittingSize of:</p>

<pre><code>- (CGSize) systemLayoutSizeFittingSize:(CGSize)targetSize withHorizontalFittingPriority:(UILayoutPriority)horizontalFittingPriority verticalFittingPriority:(UILayoutPriority)verticalFittingPriority
{
    self.collectionView.frame = CGRectMake(0, 0, targetSize.width, FLT_MAX);
    [self.collectionView layoutIfNeeded];

    CGSize collectionViewContentSize = self.collectionView.collectionViewLayout.collectionViewContentSize;
    CGFloat verticalPadding = fabs(self.collectionViewTopPaddingConstraint.constant) + fabs(self.collectionViewBottomPaddingConstraint.constant);
    CGSize cellSize = CGSizeMake(collectionViewContentSize.width, collectionViewContentSize.height + verticalPadding);

    return cellSize;
}
</code></pre>

<p>The call to layoutIfNeeded now causes a <code>*** Assertion failure in -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3599.6/UIFlowLayoutSupport.m:823</code></p>

<p>Am I violating some ethical rule by calling layoutIfNeeded within systemLayoutSizeFittingSize?  Is there some better method to calculate a collection view's content size when it is using self-sizing cells?  I would rather not have to move from auto layout to doing these size calculations in code, but that is certainly a worst case option.</p>