我在自定义 UITextView 的初始化中调用它:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textChanged:)
name:UITextViewTextDidChangeNotification
object:self];
当我以编程方式设置 textView.text = @""
时,未调用方法 textChanged
对我做错了什么有什么想法吗?
最佳答案
你不应该将self
传递给最后一个参数,这个参数是notificationSender,这意味着你只想观察self
发送的通知。
像这样的观察者:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textChanged:)
name:UITextViewTextDidChangeNotification
object:nil];
希望对您有所帮助。
关于ios - UITextView UITextViewTextDidChangeNotification 未在文本的编程更改中调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29631012/