UIKeyCommand
我通过从我的视图控制器提供实例来支持我的 iOS 应用程序中的键盘快捷键。
下面的工作就像一个魅力,每次按下时都会调用提供的选择器e:
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (NSArray *)keyCommands {
return @[
[UIKeyCommand keyCommandWithInput:@"e" modifierFlags:0 action:@selector(foo:)]];
];
}
但是,我希望关键命令是⌘</kbd>+e, or
[UIKeyCommand keyCommandWithInput:@"e" modifierFlags:UIKeyModifierCommand action:@selector(foo:)]
这仍然有效,有点。第一次按就不行了⌘</kbd>+e, but it will work like a charm after that. Why does that happen and how can I fix it?