title: Variable height CollectionView inside a self-sized TableView cell with AutoLayout on iOS8+
body: <p>I have a <code>UITableView</code> with self-sized cell's height using <code>UITableViewAutomaticDimension</code> and AutoLayout constraints. On one of prototype cells I need to add <code>UICollectionView</code> with <code>UICollectionViewFlowLayout</code> which will layout cells vertically in a single column for Compact Size Classes or in grid of 3 columns for Regular Size Classes. The height of the collection view is therefore dynamic and the layout may change even on rotation on iPhone 6 Plus (Compact->Regular).</p>
  
  <p>I setup my tableview with custom prototype cells in storyboard and add the custom collectionview into a prototype cell, AutoLayout constraints always to zero to the corresponding edge of the superview (leading, trailing, top, bottom = 0 to superview) ... collectionView->tableviewContentView->tableviewCell.</p>
  
  <p>I need the variable height of the collection view to drive the height of the tableview prototype cell. So far I am always getting the following AutoLayout error on runtime.</p>
  
  <pre><code>Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
  </code></pre>
  
  <p>Can you please suggest the right approach to this? Thank you!</p>
  
  <p><strong>Main TableViewController:</strong></p>
  
  <pre><code>class TableViewController: UITableViewController {
      override func viewDidLoad() {
          super.viewDidLoad()
          tableView.estimatedRowHeight = 200.0
          tableView.rowHeight = UITableViewAutomaticDimension
      }
      /// ... plus tableview datasource functions
  }
  </code></pre>
  
  <p><strong>CollectionView:</strong></p>
  
  <pre><code>class AttachmentCollectionView: UICollectionView, UICollectionViewDataSource, UICollectionViewDelegate {
  
      override func awakeFromNib() {
          let nib = UINib(nibName: Constants.AttachmentCollectionView.cellNibName, bundle: nil)
          registerNib(nib, forCellWithReuseIdentifier: Constants.AttachmentCollectionView.cellIdentifier)
          collectionViewLayout = attachmentFlowLayout()
          dataSource = self
          delegate = self
          backgroundColor = UIColor.whiteColor()
      }
  
      private func attachmentFlowLayout() -&gt; UICollectionViewFlowLayout {
          let layout = UICollectionViewFlowLayout()
          layout.scrollDirection = .Vertical
          layout.itemSize = CGSize(width: 70, height: 50)
          layout.sectionInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
          layout.minimumLineSpacing = 0.0
          layout.minimumInteritemSpacing = 0.0
          layout.headerReferenceSize = CGSizeMake(0.0, 0.0)
          layout.footerReferenceSize = CGSizeMake(0.0, 0.0)
          return layout
      }
      // ...plus collectionview datasource functions
  }
  </code></pre>