I am using Xcode 8.2.1 with Swift 3. I have one custom UITableViewCell containing a UITextView. When I type into the textView, the custom cell automatically gro
Firstly, from storyboard or in your tableView Cell class set the textviews NumberOfLines = 0 .
In the height for row delegate have
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
In your viewdidLoad add these lines:
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 140
In the tableViewController
func updateCellHeight(indexPath: IndexPath, comment: String) {
let currentCellLyricVal = self.traduzioneArray[indexPath.row]["rics"]
tempIndexArray.removeAll()
for (index,element) in traduzioneArray.enumerated() {
let lyricVal = element["rics"]
if currentCellLyricVal == lyricVal {
tempIndexArray.append(index)
}
}
for index in tempIndexArray {
self.traduzioneArray[index]["ione"] = comment
}
tableView.reloadRows(at: [IndexPath(row: 11, section: 1),IndexPath(row: 13, section: 1)], with: UITableViewRowAnimation.none)
}
By having the lines set to 0 and auto dimension height the cells automatically resize. Please also verify that you set your custom cells delegate to self in yourcellForRowmethod.