gpt4 book ai didi

ios - 使用 UIKeyCommand 检测连续按键

转载 作者:技术小花猫 更新时间:2023-10-29 10:09:29 26 4
gpt4 key购买 nike

是否可以连续按键?

我正在使用 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中确实是不可能的。

关于ios - 使用 UIKeyCommand 检测连续按键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21020814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com