首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用返回/输入键生成UIKeyCommand?

如何使用返回/输入键生成UIKeyCommand?
EN

Stack Overflow用户
提问于 2014-02-25 22:21:52
回答 1查看 4.1K关注 0票数 19

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

代码语言:javascript
复制
UIKeyCommand *selectCommand = [UIKeyCommand keyCommandWithInput:@"\n" modifierFlags:0 action:@selector(chooseSelection:)];

enter键没有全局常量,就像“向上”、“向下”、“左”、“右”和“转义”(来自UIResponder.h)一样:

代码语言:javascript
复制
// 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);

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-26 15:28:25

使用@"\r"进行回车而不是对换行符使用@"\n"应该有效。

票数 43
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22027522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档