title: UICollectionView Self Sizing Cells with Auto Layout
body: <p>I'm trying to get self sizing <code>UICollectionViewCells</code> working with Auto Layout, but I can't seem to get the cells to size themselves to the content. I'm having trouble understanding how the cell's size is updated from the contents of what's inside the cell's contentView.</p>
  
  <p>Here's the setup I've tried:</p>
  
  <ul>
  <li>Custom <code>UICollectionViewCell</code> with a <code>UITextView</code> in its contentView.</li>
  <li>Scrolling for the <code>UITextView</code> is disabled.</li>
  <li>The contentView's horizontal constraint is: "H:|[_textView(320)]", i.e. the <code>UITextView</code> is pinned to the left of the cell with an explicit width of 320.</li>
  <li>The contentView's vertical constraint is: "V:|-0-[_textView]", i.e. the <code>UITextView</code> pinned to the top of the cell.</li>
  <li>The <code>UITextView</code> has a height constraint set to a constant which the <code>UITextView</code> reports will fit the text.</li>
  </ul>
  
  <p>Here's what it looks like with the cell background set to red, and the <code>UITextView</code> background set to Blue:
  <img src="https://i.stack.imgur.com/orihJ.png" alt="cell background red, UITextView background blue"></p>
  
  <p>I put the project that I've been playing with on GitHub <a href="https://github.com/rawbee/SelfSizingCollectionViewCells" rel="noreferrer">here</a>.</p>