OGeek|极客世界-中国程序员成长平台

标题: ios - 如何检测 iOS 8 中按下的键盘 "PAGE UP"键? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 02:28
标题: ios - 如何检测 iOS 8 中按下的键盘 "PAGE UP"键?

我想检测用户何时按下“page up”或“page down”键。

我使用了 UITextView[UIKeyCommand keyCommandWithInput: modifierFlags: action:],

它适用于 iOS 7。

[UIKeyCommand keyCommandWithInput:[NSString hexToString"0b"] modifierFlags:0 action: @selector(pageUpKeyPressed]

(PageUp: 0b, PageDown: 0c)

但它不适用于 iOS8。

在 iOS 8 上是否有检测“page up/down”键?



Best Answer-推荐答案


我注意到预定义的常量 UIKeyInputUpArrow 等只是包含符号名称的字符串,例如 @"UIKeyInputUpArrow"。所以我尝试使用

[UIKeyCommand keyCommandWithInput"UIKeyInputPageUp" 
                    modifierFlags:0 
                           actionselector(pageUpKeyPressed];

只是一时兴起。瞧,它起作用了! (在 iOS 10 中) 不知道这是否有资格使用未记录的 API。使用它可能会或可能不会让您的应用被 App Store 拒绝。

关于ios - 如何检测 iOS 8 中按下的键盘 "AGE UP"键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26214056/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4