title: How to set UITableViewCell Height according to UICollectionView Content size?
body: <p>I have a <strong>UITableView</strong> and Inside that I have two <code>UICollectionViews</code>.</p>
  
  <p>My requirement is that I have to scroll first <code>UICollectionView</code> Horizontally.
  And I have to scroll <code>UITableView</code> vertically Because I don't want to scroll Second <code>UICollectionView</code>.  </p>
  
  <p>In Image you can see that first (Header 'Folder') <code>UICollectionView</code> I have to scroll horizontally and second (Header 'Product') <code>UICollectionView</code> I don't want to scroll vertically because I have to scroll Complete <code>UITableView</code>.</p>
  
  <p>Both <code>collectionView</code> are in <code>TableViewCell</code> and I have disable scrolling of second <code>UICollectionView</code>.</p>
  
  <p>I have to add and delete a product then I how can I set the <code>TableViewSecond</code> Cell height that content should come.</p>
  
  <p><img src="https://i.stack.imgur.com/jnyZil.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/VVOXTl.png" alt="enter image description here"></p>
  
  <p>Here is my code:   </p>
  
  <pre><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      if (0 == indexPath.section) {
          var addFolderCell = tableView.dequeueReusableCell(withIdentifier: "AddFolderCell") as? AddFolderCell
  
          if(nil == addFolderCell) {
              let nib:Array = Bundle.main.loadNibNamed("AddFolderCell", owner: self, options: nil)!
              addFolderCell = nib[0] as? AddFolderCell
          }
  
          addFolderCell?.collectionView.delegate = self
          addFolderCell?.collectionView.dataSource = self
  
          return addFolderCell!
      } else {
          let identifier = "CreateFolderCell"
          var createFolderCell = tableView.dequeueReusableCell(withIdentifier: identifier) as? CreateFolderCell
  
          if(createFolderCell == nil) {
              let nib:Array = Bundle.main.loadNibNamed("CreateFolderCell", owner: self, options: nil)!
              createFolderCell = nib[0] as? CreateFolderCell
          }
  
          return createFolderCell!
      }
  }
  
  //Height for row.
  func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
      //let index : NSIndexPath = NSIndexPath(row: 0, section: 1)
      if 0 == indexPath.section {
          return 135
      }
      return 300
  }  
  </code></pre>
  
  <p>//Header height.  </p>
  
  <pre><code>func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -&gt; CGFloat {
      return 20
  }
  
  func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -&gt; String? {
      return sectionsArray[section] as? String
   }
  }
  
  extension GroupDataView : UICollectionViewDelegate,UICollectionViewDataSource {
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
        return 4
    }
  
   func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AddFolderCollectionCell", for: indexPath) as! AddFolderCollectionCell
  
      //cell.backgroundColor = UIColor.white
      cell.layer.borderWidth = 0.4
      cell.layer.borderColor = UIColor.lightGray.cgColor
      cell.layer.cornerRadius = 2
      //CreateCardView(viewCorner: cell.cardView) //cell.cardView
      return  cell
    }
  }  
  </code></pre>
  
  <p>//MARK: Collection View Layout  </p>
  
  <pre><code>extension GroupDataView : UICollectionViewDelegateFlowLayout {
  
   func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
       return CGSize(width: 90, height: 130)
    }
  }
  </code></pre>
  
  <p>What can I do? How can I set the height for tableView?</p>