Drop pin in center of the screen, MKMapView

爷,独闯天下 提交于 2019-12-19 04:10:59

问题


I have a function that drop pin with this code:

ParkPlaceMark *placemark=[[ParkPlaceMark alloc] initWithCoordinate:location];
[mapView addAnnotation:placemark];

How to put this pin on center of the screen?

I want something similar to Uber app: http://cl.ly/362q153W461Y1g3X1o04

User is located, dropped is red pin. Then, user can set custom location (in Uber's case, where they want to be picked with taxi cab), and when tap to button to confirm that location. When user setting custom location, custom location pin is centered on screen, and only map is moving.

There is some sample with this on the Internet, or can you help me with some short sample?


回答1:


Assuming that placemark implements the MKAnnotation protocol, you can set the coordinate property of placemark to the value of the centerCoordinate property of your mapView object.

This will mean that the placemark will always be placed on the map at the coordinate that is at the centre of where the mapView is currently looking.

Hope this helps. :)



来源:https://stackoverflow.com/questions/5471361/drop-pin-in-center-of-the-screen-mkmapview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!