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
Once you update the data set with the new data. Reload the particular cells with the updated data set.
func updateCellHeight(indexPath: IndexPath, comment: String) {
DispatchQueue.main.async {
let currentCellLyricVal = self.traduzioneArray[indexPath.row]["rics"]
tempIndexArray.removeAll()
for (index,element) in traduzioneArray.enumerated() {
let lyricVal = element["rics"]
//You have to skip the current cell. by checking index != indexPath.row
if currentCellLyricVal == lyricVal, index != indexPath.row {
tempIndexArray.append(index)
}
}
for index in tempIndexArray {
self.traduzioneArray[index]["ione"] = comment
let updatedIndexPath = IndexPath(row: index, section: indexPath.section)
if let visibleCellIndexPaths = tableView.indexPathsForVisibleRows {
if visibleCellIndexPaths.contains(updatedIndexPath) {
tableView.reloadRows(at: [updatedIndexPath], with: .automatic)
}
}
}
}
}
NOTE: If the modified data set cells are visible then only we have to reload the particular cells.