开发者

iPhone: Is it safe to call textViewDidChange?

开发者 https://www.devze.com 2023-03-08 03:51 出处:网络
I\'m 开发者_开发百科looking at code in a UIViewController that conforms to the UITextViewDelegate protocol and has an instance variable called someTextView.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消