【问题标题】:How can I make a UIKeyCommand with the return/enter key?如何使用返回/输入键制作 UIKeyCommand?
【发布时间】:2014-03-28 11:06:10
【问题描述】:

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

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

回车键没有全局常量,就像上、下、左、右和转义一样(来自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);

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

【问题讨论】:

    标签: ios objective-c ios7 uiresponder uikeycommand


    【解决方案1】:

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

    【讨论】:

    • 你可能想要\r 而不是\n
    猜你喜欢
    • 2017-03-08
    • 2013-03-08
    • 2014-03-30
    • 2021-08-22
    • 2014-01-28
    • 2023-04-02
    • 2016-09-18
    • 2014-06-05
    • 1970-01-01
    相关资源
    最近更新 更多