- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
有没有办法检测 iPad 是否连接了外接(蓝牙或 USB)键盘?
最佳答案
一种间接且 SDK 安全的方法是将文本字段设置为第一响应者。如果存在外部键盘,则不应发布 UIKeyboardWillShowNotification
本地通知。
Update: This is no longer true since iOS 9, however you may use the keyboard dimensions to determine if a hardware or software keyboard is involved. See How to reliably detect if an external keyboard is connected on iOS 9? for details.
您可以收听 "GSEventHardwareKeyboardAttached"
(kGSEventHardwareKeyboardAvailabilityChangedNotification
) Darwin 通知,但这是一个私有(private) API,因此如果您使用此 API,您的应用可能会被拒绝.要检查外部硬件是否存在,请使用私有(private) GSEventIsHardwareKeyboardAttached()
函数。
UIKit 监听此并相应地设置 UIKeyboardImpl.isInHardwareKeyboardMode
属性,但这同样是私有(private) API。
关于ios - 如何检测 iPad 上是否存在外接键盘?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2893267/
假设我有一个音频 iPhone 应用程序,它从麦克风获取输入。 现在,虽然我自己还没有尝试过,但我相信用户可以使用插入 phonojack socket 的外部麦克风。 这意味着我的音频单元可能正在接
我是一名优秀的程序员,十分优秀!