问题
When I try to place a pin in the center of the map using MKMapView's centerCoordinate it puts a pin roughly in the center, but it's several pixels south of the true center of the map.
I tried converting the map's center point to a coordinate MKMapView.convertPoint(MKMapView.center) and that worked perfectly on ios8 but on ios7 is still off (now its south and west of the true center).
Anyone know how to determine how "off" the center coordinate is so I can adjust?
I need this because I am placing a crosshair image over the map and need the pin to appear in the center of the crosshair. I've verified with a ruler that the crosshair is centered on the map, it's the pin that is off.
回答1:
Well I still don't know why in iOS7 MKMapView.convertPoint(MKMapView.center) differs from MKMapView.centerCoordinate, but did figure out why .centerCoordinate was off.
Part of the map was under the status bar and I ruled the center based on the visible part and overlaying images centered on the visible part, but the map computed center based on the whole map. So once I fixed the map not running under the status bar .centerCoordinate works and, on iOS7, works better than MKMapView.center.
来源:https://stackoverflow.com/questions/27758271/mkmapview-centercoordinate-not-exact