如何知道UITextView何时成为第一响应者 [英] How to know when UITextView became first responder

查看:974
本文介绍了如何知道UITextView何时成为第一响应者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当uitextview成为第一响应者时如何处理。我在文本视图中有文本,我想在视图变为活动时想要清除文本。我怎样才能做到这一点?由于事先

How to handle when uitextview became first responder. I have text in text view and I want when the view became active want to clear the text. How can I do that? Thanks in advance

推荐答案

您绝对可以使用的 UITextViewDelegate 方法:

You can definitely use a UITextViewDelegate method of:

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView

只需返回YES并拦截该方法。你也可以做到这一点对 UITextFields UITextFieldDelegate

Just return YES and intercept inside that method. You can also do it for UITextFields with UITextFieldDelegate and:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField

希望有所帮助。

这篇关于如何知道UITextView何时成为第一响应者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆