如何在 ios9 (Ipad) 中隐藏键盘

How to hide KeyBoard in ios9 (Ipad)

我在textField中编辑文本,并将UIKeyboardWillHideNotification添加到通知中心

点击键盘右下角的键盘图标隐藏键盘。

但我发现快捷方式栏 (paste/undo ) 仍然存在,而且我没有收到通知 (UIKeyboardWillHideNotification)。 它在 ios8 上运行正常。

-->点击键盘图标

]

当点击键盘上的键盘图标时,会触发ios8中的UIKeyboardWillHideNotification,然后我resignFirstResponder for textField并使textfield丢失cursor.But它无法触发[=中的UIKeyboardWillHideNotification 32=]。所以我认为这是由于单击 ios9 中的键盘图标时键盘没有完全隐藏(工具栏)造成的。我想知道如何在 ios9 中单击键盘图标时完全隐藏键盘。或单击键盘图标时退出文本字段的第一个响应的任何其他解决方案。

谢谢

试试这个库,它会自动管理所有键盘的隐藏和显示。

将此行粘贴到 didFnishLaunchingWithOption 方法中 AppDelegate

IQKeyboardManager.sharedManager().enable = true

KeyboardManager

"it is showing only in simulator if you try on device it will hide shortcuts also hide on device." – 约翰尼·库马尔