title: How to add UITextView to custom UITableViewHeaderFooterView?
body: <p>Requirement: I want to add a row to UITableView whenever I type in the UITextView of UITableViewHeaderFooterView and click on the send button. UITableViewHeaderFooterView must be a reusable class.</p>
  
  <p>I am not able to figure out where to add the UITextViewDelegate method(Whether in the custom class itself or in the main class where I use it.)</p>
  
  <p>I followed <a href="https://jayeshkawli.ghost.io/add-headers-and-footers-to-tableview-sections/" rel="nofollow noreferrer">this</a> tutorial to create a custom footer class.</p>
  
  <p>Logic for textViewDidChange</p>
  
  <pre><code>func textViewDidChange(_ textView: UITextView) {
          let size = CGSize(width: view.frame.width - (sendButtonWidthConstraint.constant + textViewLeadingConstraint.constant), height: .infinity)
          let estimatedSize = textView.sizeThatFits(size)
  
          if estimatedSize.height &gt;= self.textViewMaxHeight
          {
              textView.isScrollEnabled = true
          }
          else {
              textViewHeightConstraint.constant = estimatedSize.height
              containerViewHeightConstraint.constant = textViewHeightConstraint.constant + textViewBottomConstraint.constant + textViewTopConstraint.constant
              sendButtonBottomConstraint.constant = (containerViewHeightConstraint.constant - sendButtonHeightConstraint.constant)/2
              textView.isScrollEnabled = false
          }
      }
  </code></pre>
  
  <p>PS: Basically, I am trying to develop the comments feature of Instagram.</p>