一旦UITextView成为iPhone SDK中的第一响应者,如何隐藏键盘?
在我的 iPhone 应用程序中,当我单击 UITextView 键盘变得可见时,
我尝试在“textDidEndOnExit”事件上使用 resignFirstResponder 但键盘不会隐藏。
隐藏键盘应该怎么做?
请帮助和建议, 谢谢。
In my iPhone App when I click on UITextView keyboard becomes visible
I try to use resignFirstResponder on "textDidEndOnExit" event but the keyboard does not hide.
What should be done to hide the keyboard?
please Help and Suggest,
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是关于这个主题的另一个主题:
如何在空白区域时隐藏键盘触摸 iPhone
我想这可以帮助你。
Here another thread about this topic:
how to hide the keyboard when empty area is touched on iphone
i think this can help you.
我建议您在键盘上方保留一个工具栏和一个名为“关闭”的按钮。单击关闭按钮时,退出您的响应者并隐藏工具栏。在textView中textViewShouldBeginEditing显示工具栏。默认隐藏工具栏。
I would suggest you to keep a toolbar and inside a button called "Dismiss" just above the keyboard. resign your responder and hide the toolbar when dismiss button is clicked. In the textView textViewShouldBeginEditing show the toolbar. Default hide the toolbar.
如果您希望 UITextView 不允许回车,并在用户按下返回键时关闭(或者如果您更改了返回键类型则完成),则实现 UITextViewDelegate 协议并使用类似以下内容:
If you want your UITextView to not allow carriage returns, and close when the user presses the return key (or Done if you have changed the return key type) then implement the UITextViewDelegate protocol and use something like:
创建一个 UIButton 或 UiBarButton 并为其分配一个方法,其中写入 [textView resignFirstResponder];
Make a UIButton or UiBarButton and assign it a method in which write [textView resignFirstResponder];
返回否;不会让你的键盘出现。希望它有帮助。你不需要任何工具栏或其他东西。尝试一下......
return No; wont allow your keyboard to appear.Hope it helps.You will not require any toolbar or something.Give it a try...