简体   繁体   中英

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).

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. 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)

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. 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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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