简体   繁体   English

如何在iPhone上“关闭键盘”?

[英]How to make “dismiss keyboard” on iPhone?

任何人都可以告诉我如何在iPhone的虚拟键盘上添加“关闭键”?

You can add an InputAccessoryView which will sit on top of the virtual keyboard (the height is adjustable but the width will always be the width of the keyboard). 您可以添加一个位于虚拟键盘顶部的InputAccessoryView (高度可调,但宽度始终是键盘的宽度)。

If you open the Safari app, when you tap into a textfield, you'll see a bar above the keyboard, this is an example of an InputAccessoryView 如果您打开Safari应用程序,当您点击文本字段时,您将在键盘上方看到一个条形图,这是一个InputAccessoryView的示例

On this accessory view, you can add a button, that when clicked will resign first responder to all of all the appropriate fields on the current view. 在此附件视图中,您可以添加一个按钮,单击该按钮会将第一响应者重新签名到当前视图上的所有相应字段。 This will dismiss the keyboard, no matter what what is currently in focus. 无论目前关注的是什么,这都会解雇键盘。

I doubt it is a proper way to add button to a standard keyboard. 我怀疑这是一个向标准键盘添加按钮的正确方法。 You should add a button to your view which "tells" your controller (via addTarget ...) to send resignFirstResponder message to the text field or search bar that has called the keyboard 你应该添加一个按钮到您的视图,其“告诉”你的控制器(通过addTarget ...)发送resignFirstResponder消息文本字段或搜索栏已调用键盘

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM