xcode 如果键盘在 ios 应用程序中可见,如何以编程方式检查 swift
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30209299/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to programaticly check with swift if keyboard is visible in ios app
提问by user2993422
In my app, I have a table view with text labels inside. When a user presses on one of the text labels, the keyboard is shown, but each time the table is reloading, the keyboard disappears. I want to add a check (when the table is reloading) to see if the keyboard is up, and if so , then to make it visible again after reloading is finished. My question is - how can I check if the keyboard is visible? any help will be appreciated. thanks
在我的应用程序中,我有一个带有文本标签的表格视图。当用户按下其中一个文本标签时,会显示键盘,但每次重新加载表格时,键盘都会消失。我想添加一个检查(当表重新加载时)以查看键盘是否已启动,如果是,则在重新加载完成后使其再次可见。我的问题是 - 如何检查键盘是否可见?任何帮助将不胜感激。谢谢
回答by Azat
There are UIKeyboardWillShowNotification
and UIKeyboardWillHideNotification
notifications of NSNotificationCenter
. Just subscribe to them
有UIKeyboardWillShowNotification
和UIKeyboardWillHideNotification
通知NSNotificationCenter
。只需订阅他们