如何在 UITextField 的触摸事件上不显示键盘?
好吧,我知道这个主题已经在这里讨论过好几次了,但是在我看过的所有许多示例中,我一直无法找到我需要的答案。我所拥有的只是一个 UITextField
,当我单击它时,我需要键盘不显示。相反,我显示了一个 UIPopoverController
。
我已经实现了这个方法:
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
[textField resignFirstResponder];
NSLog(@"here");
return NO;
}
这应该使键盘保持按下状态,但我无法启动此方法!我缺少什么?
谢谢
ok, I know that this topic has been addressed several times on here, but in all of the MANY examples I have looked at, I have been unable to find the answer I need. All I have is a UITextField
, and when I click on it, I need the keyboard to NOT show-up. Instead, I have a UIPopoverController
that is showing up.
I have implemented this method:
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
[textField resignFirstResponder];
NSLog(@"here");
return NO;
}
Which should make it so the keyboard stays down, but I can't get this method to fire! What am I missing?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您忘记了将此代码驻留在文本字段的委托中的对象。您是否在 Interface Builder 中拖动委托或设置了
textField.delegate = self
行。I think your forgot to make the object this code lives in the delegate for the textField. Did you drag the delegate in Interface Builder or set the line
textField.delegate = self
.嘿使用文本字段的委托
在 .h 中使用和在 .m 中使用 textField.delegate=self;
hey use the delegate of textfield field
in .h with and in .m with textField.delegate=self;