0

I have apps created in Xcode 5 with mkMapView working well. Recently created a new app in Xcode 6.1 and dragged old storyboard scenes and view controllers to the new app. The map view now shows a blank screen and no annotations on IOS 7 but worked on IOS 8. I added a button and now the map view is blank on IOS 8 as well. I deleted and recreated the view in storyboard with a map view inside a view inside a view controller by dragging from object templates. The map was still blank. After debugging I see that regionWillChangeAnimated and regionDidChangeAnimated show repeated setRegion events that set the region to 0.0 coordinates (before and after I set the correct region).

Finally removed the mkMapView from the storyboard view and created it using code.

//Create the map view
_mkMapView = [[MKMapView alloc] initWithFrame:self.view.frame];
_mkMapView.mapType = MKMapTypeSatellite;
_mkMapView.delegate = self;
[self.view addSubview:_mkMapView];
[self.view  setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
self.view.alpha = 1.0;
_mkMapView.mapType = MKMapTypeStandard;
_mkMapView.pitchEnabled = NO;
//Set me as map delegate
_mkMapView.delegate = self;

The zero setRegion events now do not appear & map works OK. Is there something in the storyboard I should be setting? Why would a storyboard created view be causing repeated setRegion events with zero coordinates?

0

1 Answer 1

0

It sounds like a problem with your constraints when you were creating the map view in the storyboard. You had no size constraints so the map was zero size so the region was zero size.

The map was never "blank"; it was missing entirely. An object with insufficient (ambiguous) constraints cannot be drawn. It is just chance that this ever worked; unfortunately, ambiguous constraints do not cause an error message, and sometimes the runtime will actually resolve the ambiguity in a way that causes the view to appear, so you thought everything was okay when it wasn't. Eventually the trouble was exposed.

1
  • Thanks - I was caught by Xcode 6 defaulting "Use Size Classes" on
    – sfr14
    Nov 17, 2014 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.