I m doing an iOS project using swift 2, I have a UITableView with custom cells. I have one cell with a UITextView and a simple label, and I wan't to get the value of this UITextView when it's modified, but it's not like UITextFields, I can't use on edit begin method. How can I do that ?
Here is my code to define my custom cell :
let cell = tableView.dequeueReusableCellWithIdentifier(CurrentFormTableView.CellIdentifiers.ParagraphCell, forIndexPath: indexPath) as! ParagraphCell cell.display(block) cell.selectionStyle = UITableViewCellSelectionStyle.None tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 160.0 return cell And here is my ParagraphCell.swift
import UIKit protocol ParagraphCell { func update ParagraphCell(cell: ParagraphCell, rep: String) } class ParagraphCell: UITableViewCell { @IBOutlet weak var titleLabel: UILabel! @IBOutlet weak var answerField: UITextView! var delegate: ParagraphCell Delegate? override func awakeFromNib() { super.awakeFromNib() // Initialization code let borderColor : UIColor = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 1.0) answerField.layer.borderWidth = 0.5 answerField.layer.borderColor = borderColor.CGColor answerField.layer.cornerRadius = 5.0 } override func setSelected(selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) // Configure the view for the selected state } func display(block: Block){ titleLabel.text = block.title answerField.text = "" } //THIS METHOD IS NEVER CALLED... func textViewDidChange(textView: UITextView) { //Handle the text changes here print(textView.text); //the textView parameter is the textView where text was changed delegate?.update ParagraphCell(self, rep: textView.text) } }