I'm 开发者_开发百科looking at code in a UIViewController
that conforms to the UITextViewDelegate
protocol and has an instance variable called someTextView
.
someTextView.text = @"some text";
[self textViewDidChange:someTextView];
Is that safe? That doesn't look Kosher to me. Is it even necessary to call textViewDidChange:
? Won't it get called automatically by someTextView.text = @"some text"
?
I'm debugging this error iPhone Objective-C: Keyboard won't hide with resignFirstResponder, sometimes
read the discussion of 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.
If it's safe and a good idea to call (UIView-) delegate methods manually depends on the code inside of the method. Sometimes there are valid reasons to do this.
But your bug is most likely not caused by this snippet.
精彩评论