如何响应外部键盘箭头键?
我知道以前有人问过这个问题,我见过的唯一答案是“不需要外部键盘,因为它违反了 UI 准则”。但是,我想使用这样的脚踏板: http://www.bilila.com/page_turner_for_ipad在我的应用程序中的页面之间进行更改(除了滑动之外)。该翻页器模拟键盘并使用向上/向下箭头键。
所以这是我的问题:我如何响应这些箭头键事件?正如其他应用程序所管理的那样,这一定是可能的,但我却一片空白。
I know this has been asked before, and the only answers I've seen are "Don't require an external keyboard, as it goes against UI guidelines". However, I want to use a foot pedal like this: http://www.bilila.com/page_turner_for_ipad to change between pages in my app (in addition to swiping). This page turner emulates a keyboard and uses the up/down arrow keys.
So here is my question: how do I respond to these arrow key events? It must be possible as other apps manage, but I'm drawing a blank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于那些正在 iOS 7 下寻找解决方案的人 - 有一个名为 keyCommands 的新 UIResponder 属性。创建 UITextView 的子类并实现 keyCommands,如下所示...
For those who are looking for a solution under iOS 7 - there is a new UIResponder property called keyCommands. Create a subclass of UITextView and implement keyCommands as follows...
已排序!我只是使用 1x1px 文本视图并使用委托方法
textViewDidChangeSelection:
编辑:对于 iOS 6,我必须将文本视图更改为 50x50px(或至少足以实际显示文本)工作
当踏板断开连接时,我还设法抑制屏幕键盘。
这是我在 viewDidLoad 中的代码:
keyboardShown
在我的头文件中被声明为bool
。然后添加这些方法:
我希望这段代码可以帮助其他正在寻找此问题解决方案的人。请随意使用它。
Sorted! I simply use a 1x1px text view and use the delegate method
textViewDidChangeSelection:
EDIT: For iOS 6 I had to change the text view to 50x50px (or at least enough to actually display text) for this to work
I also managed to suppress the on-screen keyboard when the pedal is disconnected.
This is my code in viewDidLoad:
keyboardShown
is declared as abool
in my header file.Then add these methods:
I hope this code helps someone else who is looking for a solution to this problem. Feel free to use it.