问题描述
我的应用程序需要知道外部键盘连接或否。我怎么知道呢?请不要私人API。 :)
My application need to know are external keyboard connect or no. How could i do to know that? No Private API please. :)
推荐答案
如果这与iOS有关,我不确定为什么你想要将其检测为硬件键盘与软件键盘完全相同(除了声音,亮度等一些额外的快捷方式,你的应用程序不应该使用它们。)
If this is iOS related, I'm not sure why you'd want to detect this as the hardware keyboard acts exactly the same as the software keyboard (except with a few extra shortcuts for sound, brightness etc. which your app shouldn't use anyway).
如果你是考虑到屏幕空间,软件键盘在显示或隐藏时仍会发送通知,因此您可以对其进行响应。例如,假设您已启用软件键盘,然后连接外部键盘。软件键盘将隐藏,并将发布 UIKeyboardWillHideNotification 。所以你可以回应。
If you're considering screen space, then the software keyboard will still send it's notifications when it is displayed or when it is hidden, so you can respond to those. For example, say you have the software keyboard up and then you connect your external keyboard. The software keyboard will hide, and will post the UIKeyboardWillHideNotification. So you can respond to that.
这篇关于如何在objective-c中检测外部键盘连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!