title: Change cell layout when traitCollection changes
body: <p>I'm having problems adjusting a cell's layout when the horizontal size class changes. </p>
  
  <p>My cell has a stackView and I want the axis to be Horizontal for Compact size class and Vertical for Regular.</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>override func traitCollectionDidChange(previousTraitCollection: UITraitCollection?) {
      if previousTraitCollection?.horizontalSizeClass != traitCollection.horizontalSizeClass {
          self.collectionView?.reloadData()
      }
  }
  
  override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! MyCollectionViewCell
  
      switch traitCollection.horizontalSizeClass {
      case .Compact:
          cell.stackView.axis = .Horizontal
      default:
          cell.stackView.axis = .Vertical
      }
  
      return cell
  }
  </code></pre>
  
  <p>But the result is that not all cells update their layout, se the gif below.</p>
  
  <p><strong>EDIT:</strong>
  I have confirmed that the axis is changed correctly by printing in <code>cellForItem</code> and in the cell class itself. So the issue seems to be that the cells are not redrawn..</p>
  
  <p><a href="https://i.stack.imgur.com/T96ed.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T96ed.gif" alt="Cell layout problems"></a></p>
  
  <p>Any suggestions how i should solve this?</p>
  
  <p><a href="https://github.com/LarsJK/CellLayoutProblems" rel="nofollow noreferrer">Github Repo</a></p>