When I set my UITextView
programmatically like this:
[self.textView setText:@""];
The delegate method textViewDidChange:
does not get called. Is there a way I can find that without making a UITextView
subclass?
In swift you could override text var in UITextView class
class MyTextView: UITextView {
override public var text: String? {
didSet {
self.textViewDidChange(self)
}
}
}
When manually setting the text of a UITextView
with code, the textViewDidChange:
method does not get called. (If you have your text view's delegate
set, it will get called when the user edits it, though.)
One possible workaround would be to manually call textViewDidChange:
anytime you edit the text. For example:
[self.textView setText:@""];
[self textViewDidChange:self.textView];
Kind of a hackish way of doing it, but it gets the job done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With