是否可以连续按下按键?
我正在使用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中确实是不可能的.