问题描述
我想制作一个只使用 [return] 键的 UIKeyCommand.到目前为止,我已经尝试过:
UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)];
enter 键没有全局常量,就像 up、down、left、right 和 escape 一样(来自 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);
还有什么我可以尝试捕获返回/输入键的吗?
推荐答案
使用 @"\r" 回车而不是 @"\n" 换行应该可以.