Question

Before iOS6 I used to rotate the MKMapView based on the user's GPS-direction (NOT HEADING), using a subview of the MKMapView. It all worked perfectly, I initialized the view as follows:

mapView = [[MKMapView alloc] init];    
mapView.delegate = self;
mapView.clipsToBounds = FALSE;
mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;        
self.view = mapView;

And when rotating I did the following:

UIView *innerMap = [mapView.subviews objectAtIndex:0];
if([innerMap isKindOfClass:[UIView class]])
{
    innerMap.transform = CGAffineTransformMakeRotation(degreesToRadians(-lastDegrees));
}

As I said, all worked perfectly. The nice thing was then when the map rotated, it automatically scaled to the entire frame of the view and filled the black corners that the rotation created.

However, the new iOS6 Maps does not scale and fill the corners! So when it rotates, half of the view is missing and the other half is black (background-color). What have I tried?

  • Trying all different subviews of the new MKMapview (also set their resizingmask to the same value as the mapview)
  • Tried to set the contentmode to scaleToFill (also in the subviews)
  • Tried to set the autoresizes subviews to true
  • Tried to reset the frame after rotating

Unfortunately, all my attempts have no effect at all. Somehow the GoogleMaps scaled and filled the black corners automatically and the iOS Maps do not. So am I missing something here, some awesome property of UIView that I'm forgetting or is this simply not possible with the new iOS6 Maps?

Was it helpful?

Solution

What about making the MapView much larger than the screen size so when it rotates you can't seen around it?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top