我正在使用Xcode8.2.1。我的自定义单元格只包含一个UITextview。当我尝试键入第一个单元格时,它必须自动将数据输入到第二个单元格。单元格也必须以适当的高度生长。现在它的只在一个细胞工作正在增长。当我在第一个细胞的UITextview上输入数据时,我想同时生长两个细胞。请仔细阅读以下代码。
//Tableview Datasource method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: TranslateTableViewCell = tableView.dequeueReusableCell(withIdentifier: "TranslateTableViewCell", for: indexPath as IndexPath) as! TranslateTableViewCell
if let traduzioneVal = self.traduzioneArray[indexPath.row]["ione"] {
cell.translateTextView.text = traduzioneVal
}
cell.cellIndexPath = indexPath
cell.delegate = self
return cell
}
//custom delegate method calling from textViewDidChange
func updateTextView(indexPath: IndexPath, comment: String) {
self.traduzioneArray[indexPath.row]["ione"] = comment
self.traduzioneArray[indexPath.row + 1]["ione"] = comment
self.lyricsTableView.beginUpdates()
self.lyricsTableView.endUpdates()
}
//UItextview Delegate method (from custom TranslateTableViewCell class )
func textViewDidChange(_ textView: UITextView) {
self.delegate.updateTextView(indexPath: self.cellIndexPath, comment: textView.text)
}