title: UITableViewCell With UIWebView Dynamic Height
body: <p>I have a table view with cells that have a webView in them, I want the height of the cell to match the height of the webView.</p>
  
  <p>This is the code I use: </p>
  
  <pre><code>func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
      let cell = tableView.dequeueReusableCellWithIdentifier("newsCell") as! NewsTableViewCell
  
      cell.webView.loadHTMLString("test&lt;br&gt;test&lt;br&gt;test&lt;br&gt;test&lt;br&gt;test&lt;br&gt;test", baseURL: nil)
      cell.webView.delegate = self
  
      var webFrame = cell.webView.frame
      var cellFrame = cell.frame
      cell.frame = CGRectMake(cellFrame.origin.x, cellFrame.origin.y, cellFrame.width, webFrame.height + 20)
      cell.backgroundColor = UIColor.redColor()
  
      return cell
  }
  
  func webViewDidFinishLoad(webView: UIWebView) {
      println("finished loading")
      var frame = webView.frame
      frame.size.height = 1
      webView.frame = frame
  
      var fittingSize = webView.sizeThatFits(CGSizeZero)
      frame.size = fittingSize
      webView.frame = frame
  
      var height: CGFloat = frame.height
      println(height)
  
      webView.frame = CGRectMake(frame.origin.x, frame.origin.x, frame.size.width, frame.size.height)
  
      newsTable.beginUpdates()
      newsTable.endUpdates()
  }    
  </code></pre>
  
  <p>And this is the result: <a href="https://postimg.cc/image/8qew1lqjj/" rel="noreferrer">https://postimg.cc/image/8qew1lqjj/</a></p>
  
  <p>The webView is the correct height but the cell isn't, How can I fix this problem?</p>