Search code examples
iosswiftmkmapviewmkannotationview

Center of map and center of screen are different


I have a little problem in my app right now and I don't know how to resolve it !

First look at this :

enter image description here

I have an UIImageView in the center of my screen which display a fake annotation, and when the user release the map, a real annotation appear in order to display the Callout view. But my problem is that the real annotation is not displayed on center of screen , but on center of the "visible" part of the map, and take in account the transparent tab bar.

Before the transparent tab bar I just had the end of the mapView on top of tabBar, at this moment the real annotation and fake annotation were at the same position, but it's not the case anymore..

Is it possible to set an offset for the real annotation, or just move my image on top of the real annotation ?

I already tried that in the viewDidLoad method :

self.pinView.center = self.mapView.center

With no effects ..


Solution

  • It would be best to offset the fake annotation down by the height of the tab bar. You can read the tab bar height and then add that to the .y value of fake annotation.