ios – 用UIKeyCommand检测连续按键

前端之家收集整理的这篇文章主要介绍了ios – 用UIKeyCommand检测连续按键前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
是否可以连续按下按键?

我正在使用keyCommands:截取在外部键盘上按下的箭头键,但是每次只能收到1个呼叫.只要按住键,我会希望每X毫秒多次拨打一次电话,或者在按下该键并释放该键时拨打电话.

这是我的代码

- (NSArray *)keyCommands
{
    UIKeyCommand *upArrow = [UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow
                                                modifierFlags:0
                                                       action:@selector(upArrow:)];
    UIKeyCommand *downArrow = [UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow
                                                  modifierFlags:0
                                                         action:@selector(downArrow:)];
    UIKeyCommand *leftArrow = [UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow
                                                  modifierFlags:0
                                                         action:@selector(leftArrow:)];
    UIKeyCommand *rightArrow = [UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow
                                                   modifierFlags:0
                                                          action:@selector(rightArrow:)];
    UIKeyCommand *leftArrowCmd = [UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow
                                                     modifierFlags:UIKeyModifierCommand
                                                            action:@selector(leftArrowCmd:)];
    UIKeyCommand *rightArrowCmd = [UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow
                                                      modifierFlags:UIKeyModifierCommand
                                                             action:@selector(rightArrowCmd:)];
    UIKeyCommand *lCmd = [UIKeyCommand keyCommandWithInput:@"l"
                                             modifierFlags:UIKeyModifierCommand
                                                    action:@selector(lCmd:)];
    UIKeyCommand *rCmd = [UIKeyCommand keyCommandWithInput:@"r"
                                             modifierFlags:UIKeyModifierCommand
                                                    action:@selector(rCmd:)];
    UIKeyCommand *mCmd = [UIKeyCommand keyCommandWithInput:@"m"
                                             modifierFlags:UIKeyModifierCommand
                                                    action:@selector(mCmd:)];
    return @[upArrow,downArrow,leftArrow,rightArrow,leftArrowCmd,rightArrowCmd,lCmd,rCmd,mCmd];
}

解决方法

似乎这在iOS 7中确实是不可能的.
原文链接:https://www.f2er.com/iOS/337589.html

猜你在找的iOS相关文章