19

我想做一个UIKeyCommand只使用[return]密钥的。到目前为止,我已经尝试过:

UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)];

enter 键没有全局常量,就像 up、down、left、right 和 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);

还有什么我可以尝试捕获返回/输入键的吗?

4

1 回答 1

43

使用@"\r"回车而不是@"\n"换行应该可以。

于 2014-02-26T15:28:25.833 回答