Text changed event in UITextView

trycatch

New Member
#1
I have
Mã:
@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:

Mã:
func textViewDidChange(_ textView: UITextView) {
    switch (textView) {
        case messageTextView: print("blabla")
        default: break
    }
}
 

Admin

Administrator
Thành viên BQT
#2
You need to set the delegate inside viewDidLoad
Mã:
textView.delegate = self
//
Mã:
class ViewController: UIViewController , UITextViewDelegate  {
 

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top