为多个UITextField重新启动First Responder [英] Resigning First Responder for multiple UITextFields
问题描述
有一个应用程序,我动态生成多个 UITextFields
。我想在没有选择 UITextFields
的情况下辞职第一响应者(在 UITextField
之外触摸)。我怎么知道哪个 UITextField
我必须辞职第一响应者?请指出除标签概念之外的任何其他方式,因为我已尝试过。请建议正确的方向。提前致谢。
There is an application in which I am generating multiple UITextFields
dynamically. I want to resign first responder whenever the UITextFields
are not selected (touch outside the UITextField
). How can I know that of which UITextField
I have to resign first responder? Please specify any other way beyond the 'tag' concept because I have tried that. Please suggest the right direction. Thanks in advance.
推荐答案
请勿致电 resignFirstResponder
;致电$ code> endEditing:!
在任何地方拨打 endEditing:
在视图层次结构中的文本字段上方查看。它会找到第一个响应者并要求它辞职。使用 endEditing:YES
强制它或 endEditing:NO
让文本字段的委托决定是否应该结束编辑(如果您正在验证输入,则非常有用。)
Don't call resignFirstResponder
; call endEditing:
!
Call endEditing:
on any view above the text fields in the view hierarchy. It will locate the first responder and ask it to resign. Use endEditing:YES
to force it or endEditing:NO
to let the text field's delegate decide if it should end editing (useful if you are validating input).
这篇关于为多个UITextField重新启动First Responder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!