Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text changed event in UITextView

I have

@IBOutlet weak var messageTextView: UITextView

and I want that when there is a change inside the text then print to console: blabla.

I tried to add the following function, but when I change the text nothing happens:

func textViewDidChange(_ textView: UITextView) {
    switch (textView) {
        case messageTextView: print("blabla")
        default: break
    }
}
like image 667
trycatch Avatar asked Sep 10 '18 13:09

trycatch


1 Answers

You need to set the delegate inside viewDidLoad

textView.delegate = self

//

class ViewController: UIViewController , UITextViewDelegate  {
like image 103
Sh_Khan Avatar answered Oct 27 '22 10:10

Sh_Khan