如何使用return / enter键创建UIKeyCommand? [英] How can I make a UIKeyCommand with the return/enter key?
本文介绍了如何使用return / enter键创建UIKeyCommand?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想制作仅使用 [return]
键的 UIKeyCommand
。到目前为止我已经尝试过:
I'd like to make a UIKeyCommand
that uses only the [return]
key. So far I've tried:
UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)];
输入键没有全局常量,如上,下,左,右,和转义(来自 UIResponder.h
):
There's no global constant for the enter key, like there is for up, down, left, right, and escape (from UIResponder.h
):
// These are pre-defined constants for use with the input property of UIKeyCommand objects.
UIKIT_EXTERN NSString *const UIKeyInputUpArrow NS_AVAILABLE_IOS(7_0);
UIKIT_EXTERN NSString *const UIKeyInputDownArrow NS_AVAILABLE_IOS(7_0);
UIKIT_EXTERN NSString *const UIKeyInputLeftArrow NS_AVAILABLE_IOS(7_0);
UIKIT_EXTERN NSString *const UIKeyInputRightArrow NS_AVAILABLE_IOS(7_0);
UIKIT_EXTERN NSString *const UIKeyInputEscape NS_AVAILABLE_IOS(7_0);
还有什么我可以尝试捕获return / enter键吗?
Is there anything else I could try to capture the return/enter key?
推荐答案
使用 @\ r
进行回车而不是换行的@\ n
应该有效。
Using @"\r"
for carriage return instead of @"\n"
for newline should work.
这篇关于如何使用return / enter键创建UIKeyCommand?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文