我正在查看 UIViewController
中的代码,它符合 UITextViewDelegate
协议(protocol),并且有一个名为 someTextView
的实例变量。
someTextView.text = @"some text";
[self textViewDidChange:someTextView];
这样安全吗?在我看来这不符合犹太洁食。是否有必要调用 textViewDidChange:
? someTextView.text = @"some text"
不会自动调用它吗?
我正在调试此错误 iPhone Objective-C: Keyboard won't hide with resignFirstResponder, sometimes
最佳答案
阅读 textViewDidChange:
的讨论
Discussion
The text view calls this method in response to user-initiated changes to the text. This method is not called in response to programmatically initiated changes.
手动调用 (UIView-) 委托(delegate)方法是否安全且好主意取决于该方法内部的代码。有时这样做是有正当理由的。
但是您的错误很可能不是由此代码片段引起的。
关于iPhone:调用textViewDidChange安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6127768/