[英]How can I make a UIKeyCommand with the return/enter key?
I'd like to make a UIKeyCommand
that uses only the [return]
key.我想制作一个仅使用
[return]
键的UIKeyCommand
。 So far I've tried:到目前为止,我已经尝试过:
UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)];
There's no global constant for the enter key, like there is for up, down, left, right, and escape (from UIResponder.h
): enter 键没有全局常量,就像向上、向下、向左、向右和转义一样(来自
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);
Is there anything else I could try to capture the return/enter key?还有什么我可以尝试捕获返回/输入键的吗?
使用@"\\r"
回车而不是@"\\n"
换行应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.