所有文本字段的resignFirstResponder [英] resignFirstResponder for all textfields
问题描述
我正在使用 viewcontroller
上的多个 textfields
的iphone应用程序。我对 resignfirstresponder
和设置 textfield delegates
感到困惑。我已经能够在我离开文本字段时将委托设置为1,然后为该特定文本字段调用 resignfirstresponder
。
我有一个视图控制器
,包含大约7个文本字段,并且不想单独调用每个文本字段。有没有人有任何示例代码可以关闭视图控制器
上的所有 textfields
?另外如何为所有文本字段设置委托?
I'm working on an iphone app with multiple textfields
on a viewcontroller
. I'm a bit confused with resignfirstresponder
and setting textfield delegates
.I've been able to resign text fields when I set the delegate for one then call resignfirstresponder
for that particular textfield.
I have a view controller
with about 7 text fields and don't want to call each individually. Does anyone have any example code that will close all of the textfields
on a view controller
? Also how do you set the delegate for all textfields?
谢谢!
推荐答案
尝试使用此
[self.view endEditing:YES];
这会隐藏键盘,如果它出现在你的self.view的子视图中
This will hide keyboard if its presented due to a subview of your self.view
这篇关于所有文本字段的resignFirstResponder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!