title: Getting collection view cells to update after a constraint change
body: <p>I'm having a problem with auto layout in a collection view cell in iOS 9. </p>
  
  <p>During the collection view's :cellForItemAtIndexPath: I change a constraint:</p>
  
  <p>[[self rootStack] setDistribution:UIStackViewDistributionFillEqually];</p>
  
  <p>or</p>
  
  <p>[[self rootStack] setDistribution:UIStackViewDistributionFillProportionally];</p>
  
  <p>During the cell's preferredLayoutAttributesFittingAttributes: I try to force an additional round of layout:</p>
  
  <pre><code>- (UICollectionViewLayoutAttributes*) preferredLayoutAttributesFittingAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
  {
      [self setNeedsLayout];
      [self layoutIfNeeded];
  
      return layoutAttributes;
  }
  </code></pre>
  
  <p>Still, when cells are displayed, some show the effect of the constraint change and some do not. If I scroll a cell that does not display the change offscreen and then scroll back to it, it then displays the change. Moving the constraint changes to the cell's updateConstraints resulted in none of the cells showing the change on first display.</p>
  
  <p>I can fix this for the first cells that are displayed by calling reloadData on the collection view during the collection view controller's viewWillAppear:. But once I start scrolling some of the cells that come into view are not formatted correctly (unless I scroll past them and then scroll back to them).</p>
  
  <p>Is there a way I can make sure that all cells are formatted correctly the first time they are displayed?</p>