Search code examples
iphoneiosorientationmapkitquartz-graphics

Rotate a MKMapView while keeping pins in the initial orientation?


I have an app which runs in portrait mode on iPhone. One of the views in my app is a map. The area which I want to show looks much better in landscape orientation. So, I used The Quartz framework to rotate the map. The problem is, my pins are all sideways now. I'd like to know if I can tell MapKit to rotate the map, while keeping the pins oriented the correct way. Can I do this? How?


Solution

  • This is off the top of my head and thus untested in code. I also assume that you're not returning custom annotation views for your annotations already. Consequently, I wonder if you can:

    1. Set the delegate for your map view to your view controller.
    2. Implement in your view controller: - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id )annotation
    3. Return a simple MKPinAnnotationView to which you apply the same transform as you apply to your MKMapView.

    Sounds plausible on paper, I think?!