我想制作仅使用UIKeyCommand
密钥的[return]
。到目前为止,我已经尝试过:
UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)];
输入键没有全局常量,例如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);
还有什么我可以尝试捕获return / enter键吗?
答案 0 :(得分:30)
使用@"\r"
回车而不是@"\n"
换行应该有效。