increase TableView height based on cells
<p>I need to increase <code>UITableView</code> height based on <code>UITableViewCell</code> content size.
I'm using Custom Google Auto Complete. I have an <code>UITextField</code>. When I enter a letter in that <code>UITextField</code> it will call <code>shouldChangeCharactersIn</code> range delegate method. </p>

<p>Inside that method I will send dynamic request to Google AutoComplete API to get predictions result.</p>

<pre><code>func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -&gt; Bool {

    if tableView.numberOfRows(inSection: 0) &gt; 0
    {

    let newLength = (textField.text?.characters.count)! + string.characters.count - range.length
    let enteredString = (textField.text! as NSString).replacingCharacters(in: range, with:string)

    if newLength == 0 {
        tableView.isHidden = true
    }

    if newLength &gt; 0
    {
        address.removeAll()
        self.tableView.isHidden = false

        GetMethod("https://maps.googleapis.com/maps/api/place/autocomplete/json?input=\(enteredString)&amp;key=MYAPIKEY", completion: { (resultDict) in

            let resultArray = resultDict.object(forKey: "predictions")! as! NSArray

            print(resultArray.count)

            for temp in resultArray

            {
                 let newtemp = temp as! NSDictionary
                 let tempAdd = newtemp.value(forKey:"description") as! String
                let placeId = newtemp.value(forKey:"place_id") as! String
                var dict = [String : AnyObject]()
                dict["address"] = tempAdd as AnyObject?
                dict["latlong"] = placeId as AnyObject?
                self.address.append(dict as AnyObject)
                 print(newtemp.value(forKey:"description"))
                 print(self.address.count)
                self.tableView.reloadData()

            }

        })
      }
    return true
}
</code></pre>

<p>After I will store all address to Address array dynamically, I need to increase <code>UITableView</code> height based on that incoming address content.</p>

<pre><code>func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
    let cellIdentifier = "TableViewCell"
    var cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)
    if cell == nil
    {
    cell = UITableViewCell(style: .default, reuseIdentifier: cellIdentifier)
    }

    let addresstoDisp  = address[indexPath.row] as! NSDictionary
    let name = addresstoDisp.value(forKey: "address")
    cell?.textLabel?.numberOfLines = 0
    cell?.translatesAutoresizingMaskIntoConstraints = false

    cell?.textLabel?.lineBreakMode = NSLineBreakMode.byWordWrapping
    cell?.textLabel?.textAlignment = NSTextAlignment.center
    cell?.textLabel?.text = name as! String

    return cell!
}
</code></pre>

<p><code>UITableViewCell</code> height is increasing perfectly. Also I need to increase tableView height.</p>