ios - 如何使用返回/输入键创建 UIKeyCommand?

标签 ios objective-c ios7 uiresponder uikeycommand

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

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

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

还有什么我可以 try catch 返回/输入键的吗?

最佳答案

使用 @"\r" 代替 @"\n" 换行应该可行。

关于ios - 如何使用返回/输入键创建 UIKeyCommand?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22027522/

相关文章:

ios - 如何以编程方式使用自动布局排列这三个 UILabel?

ios - 底部布局指南和不同屏幕格式的一般方法

ios - icroll.js 子元素溢出 : scroll not working on IOS

objective-c - 无法在 View 层中捕获蒙版

ios - 访问从 XIB 实例化的 View subview 的最佳方式?

ios - 应用程序被杀死时的静默推送通知

ios - 第一次比较两个 UIColors 不起作用

php - TestFlight 中未收到 iOS FCM 推送通知

iphone - 从 UILongPressGestureRecognizer 上的表格 View 单元格保存数据

python - 使用 GCD 从 Cocoa 应用程序运行 Python 脚本