如何使用return/enter键创建UIKeyCommand?

pau*_*ler 16 objective-c uiresponder ios ios7 uikeycommand

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

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

输入键没有全局常量,例如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);
Run Code Online (Sandbox Code Playgroud)

还有什么我可以尝试捕获return/enter键吗?

kva*_*nce 35

使用@"\r"了回车,而不是@"\n"作为换行符应该工作.