【问题标题】:How to detect Keyboard "PAGE UP" key pressed in iOS 8?如何检测在 iOS 8 中按下的键盘“PAGE UP”键?
【发布时间】:2017-06-02 13:49:23
【问题描述】:

我想检测用户何时按下“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”键?

【问题讨论】:

  • 向上/向下页面从何而来?这是外接键盘吗? AFAIK,没有用于向上或向下翻页的 iOS 软件密钥。您可以检测箭头键 UIKeyInputUpArrow 和修饰符 UIKeyModifierControl。但是那些不会让你得到相当于 fn 向上箭头的短键盘,这是用作扩展键盘向上翻页按钮的替代品。如果您需要箭头和修饰符方面的帮助,请告诉我。
  • 我已经在这里回答了这个问题:stackoverflow.com/questions/32274319/…

标签: ios objective-c ios8


【解决方案1】:

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

[UIKeyCommand keyCommandWithInput:@"UIKeyInputPageUp" 
                    modifierFlags:0 
                           action:@selector(pageUpKeyPressed:)];

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

【讨论】:

    猜你喜欢
    • 2013-04-07
    • 1970-01-01
    • 2018-10-24
    • 2015-11-23
    • 2014-08-01
    • 1970-01-01
    • 2014-03-31
    • 2014-11-24
    • 2016-03-30
    相关资源
    最近更新 更多