UITextView 委托未获取所有方法调用

发布于 2024-08-02 10:15:57 字数 472 浏览 2 评论 0原文

我有一个 UIViewController 实现 UITextViewDelegate 并作为委托连接到我的 UITextView。每当点击文本视图时,我都会接到电话:

 - (void)textFieldDidBeginEditing:(UITextField *)sender

每当视图的内容发生变化(键盘、编程修改)时,我都会接到电话:

 - (void)textViewDidChange:(UITextView *)textView

但是当我按键盘上的 Return 键时,我没有接到电话to:

 - (BOOL)textFieldShouldReturn:(UITextField *)textField

这个方法有什么不同吗?是否需要在某个地方设置一些特殊的东西来确保我接到这个电话?

提前致谢!

I have a UIViewController that implements UITextViewDelegate and is connected as the delegate to my UITextView. Whenever the text view is tapped, I get a call to:

 - (void)textFieldDidBeginEditing:(UITextField *)sender

and whenever the contents of the view change (keyboard, programmatic modification), I get calls to:

 - (void)textViewDidChange:(UITextView *)textView

But when I hit the Return key on the keyboard, I am not getting a call to:

 - (BOOL)textFieldShouldReturn:(UITextField *)textField

Is there something different about this method? Is there something special that needs to be set somewhere to make sure I get this call?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇纵 2024-08-09 10:15:57

最好使用键盘通知而不是使用延迟。将您的 viewController 注册为该通知的观察者。我很确定这听起来不错。

Better to use keyboard notifications instead of using delagates. Register your viewController as observer for that notification. I am pretty sure that it sounds good.

缪败 2024-08-09 10:15:57

是的,不同的代表。

Yep, different delegate.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文