简体   繁体   English

键盘快捷键可移动地图视图?

[英]Keyboard shortcut to move map view?

I'm trying to implement the same feature, that Maps.app has on OS X, where when selecting the map, the arrow keys on the keyboard moves the map north/south (up/down) and east/west (left/right). 我正在尝试实现OS X上Maps.app所具有的相同功能,即在选择地图时,键盘上的箭头键可将地图向北/向南(向上/向下)和向东/向西(左/右)移动)。

I've created a sample project, added a MKMapView to the storyboard just to ensure that I've not overwritten anything in my 'real' project, but the default behavior is the same, ie. 我创建了一个示例项目,在情节提要中添加了MKMapView,只是为了确保我没有覆盖“真实”项目中的任何内容,但是默认行为是相同的。 the map is not responding to the keyboad strokes. 地图对键盘笔触没有响应。

I've searched the documentation, looking at the delegate protocols, but have been unable to finde an answer. 我已经搜索了文档,查看了委托协议,但是找不到答案。 Any ideas? 有任何想法吗? (It does not matter if its Swift or Objective-C) (它的Swift或Objective-C都没有关系)

So, after a few days thought, I've come to this solution: 因此,经过几天的思考,我得出了以下解决方案:

Create a function that moves the map (I've used setCenterCoordinate:), and trigger this from keyDown. 创建一个移动地图的函数(我使用过setCenterCoordinate :),并从keyDown触发它。 There is a little regarding zooming and moving the map that need to be thought of though. 尽管有一些关于缩放和移动地图的知识。

I'm leaving this here, in case someone can use it :) 如果有人可以使用它,我将其留在这里:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM