简体   繁体   English

如何检测iPad用户点击键盘隐藏按钮?

[英]How to detect iPad user tap on keyboard hide button?

In my app I have some complex logic surrounding the hiding and showing of the keyboard. 在我的应用程序中,我有一些复杂的逻辑围绕隐藏和显示键盘。 I am interested in detecting when the user (who has an iPad) specifically taps on the iPad keyboard hide button: 我有兴趣检测用户(谁拥有iPad)何时专门点击iPad键盘隐藏按钮:

替代文字

I am not interested in detecting when the keyboard is supposed to hide, only when the user actually physically taps on this button. 不想检测键盘应该隐藏的时间,只有当用户实际物理上点击此按钮时。 Any suggestions? 有什么建议?

Thank you! 谢谢!

I was looking for an exact same solution, and I did found it in the documentation after all. 我一直在寻找一个完全相同的解决方案,毕竟我确实在文档中找到了它。 You get a whole package of keyboard notifications: 你得到一整套键盘通知:

- UIKeyboardWillShowNotification
- UIKeyboardDidShowNotification
- UIKeyboardWillHideNotification
- UIKeyboardDidHideNotification
- UIKeyboardWillChangeFrameNotification
- UIKeyboardDidChangeFrameNotification

I was interested in "UIKeyboardWillHideNotification". 我对“UIKeyboardWillHideNotification”感兴趣。 So just implemented: 刚刚实施:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(KeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

Et voilà! Etvoilà! Hope this helps, even it's an year late answer. 希望这会有所帮助,即使这是一年的答案。

I don't think Apple allows that, I'm afraid. 我不认为Apple允许这样做。

But maybe you could create an invisible view ( view.opaque = FALSE; view.alpha = 0; ) that's placed just above the aforementioned button which receives touches as the first responder (so that you get the event) and then forwards it to the next (the keyboard). 但也许你可以创建一个看不见的视图( view.opaque = FALSE; view.alpha = 0; ),它位于上述按钮上方,接收触摸作为第一响应者(以便你得到事件),然后将其转发给下一个(键盘)。 However, I don't know if it's possible to place a view above the keyboard, even "illegally". 但是,我不知道是否可以在键盘上方放置视图,甚至是“非法”。

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

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