title: Swift: Change TableViewCell Height Dynamically and change WebView Height Dynamically
body: <p>I have a <code>TableViewController</code>, inside the <code>TableViewCell</code>, I have a <code>UIWebView</code>. I want the <code>UIWebView</code> to display some content from the internet, but I don't want the scroll effect, I want the <code>WebView</code> to have a dynamic height based on the length of the content. In addition, I want the <code>TableViewCell</code> to be able to adjust its cell height dynamically based on the dynamic height of <code>WebView</code>. Is this possible? </p>
  
  <p>This is how I implemented my <code>TableViewController</code>:</p>
  
  <pre><code>class DetailTableViewController: UITableViewController {
  
  var passPost: Posts = Posts()
  var author: Author = Author()
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      getAuthor()
  
  }
  override func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
      return 1
  }
  
  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      return 1
  }
  
  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
  
          let cell = tableView.dequeueReusableCellWithIdentifier("detailCell")
  
  let postImageUrlString = passPost.postThumbnailUrlString
          let postImageUrl = NSURL(string: postImageUrlString)
          let size = CGSize(width: 414.0, height:212.0 )
          let filter = AspectScaledToFillSizeFilter(size: size)
          (cell?.contentView.viewWithTag(1) as! UIImageView).af_setImageWithURL(postImageUrl!, filter: filter)
  
          //Set Author Avatar
  
          let authorAvatarUrlString = author.authorAvatarUrlString
          let authorAvatarUrl = NSURL(string: authorAvatarUrlString)
  
          //Mark - Give Author Avatar a Round Corner
  
          let filter2 = AspectScaledToFillSizeWithRoundedCornersFilter(size: (cell?.contentView.viewWithTag(2) as! UIImageView).frame.size, radius: 20.0)
  
          (cell?.contentView.viewWithTag(2) as! UIImageView).af_setImageWithURL(authorAvatarUrl!, filter: filter2)
  
  
          //Set Post Title and Content and so on
  
          (cell?.contentView.viewWithTag(4) as! UILabel).text = passPost.postTitle
          (cell?.contentView.viewWithTag(6) as! UIWebView).loadHTMLString("\(passPost.postContent)", baseURL: nil)
  </code></pre>
  
  <p>for the <code>heightForCellAtIndexPath</code> I did </p>
  
  <pre><code>override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -&gt; CGFloat {
      let cell = tableView.dequeueReusableCellWithIdentifier("cell") as! tableViewCell
      tableView.rowHeight = cell.theWebView.scrollView.contentSize.height
      return tableView.rowHeight
  }
  </code></pre>
  
  <p>This is working fine, except the <code>WebView</code> has a scroll effect, and the height is limited due to the limitation of the <code>TableViewCell</code>. So, how to achieve what I need?</p>