MKMapView dealloc'ed when addOverlay is called

I am having a problem disabling my mapView when I call this in - (void)viewDidLoad

NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png";
self.onlineOverlay = [[MKTileOverlay alloc] initWithURLTemplate:template];
self.onlineOverlay.canReplaceMapContent = YES;
[_mapView addOverlay:self.onlineOverlay level:MKOverlayLevelAboveLabels];

Magazine: (with zombie objects included)

*** -[VKRasterOverlayTileSource invalidateRect:level:]: message sent to deallocated instance 0xf1863e0

This only happens when I close the view controller containing the map display too quickly. If I wait a few seconds, this will not work. The view controller shuts down by unloading it from the navigation controller,

I tried several options:

  • mapViewand mapView.delegateset nilto- (void) dealloc and in - (void)viewDidDisappear
  • BOOL finishedLoadingwhich is set to FALSEwhen the view is loaded and set to TRUEwhen the delegate method of the map view is - (void)mapViewDidFinishRenderingMap:(MKMapView *)mapView fullyRendered:(BOOL)fullyRenderedcalled.
  • - (void)mapView:(MKMapView *)mapView didAddOverlayRenderers:(NSArray *)renderersseems to be called before the method is executed.

How to check if the overlay is fully added?

, ?

EDIT: . . , , , addOverlay: - .

MapView viewController .

+3
1

mapView tileOverlay. , mapView , . mapView tileOverlay.

NSString *template = @"http://tile.openstreetmap.org/{z}/{x}/{y}.png"; self.onlineOverlay = [[MKTileOverlay alloc] initWithURLTemplate:template]; self.onlineOverlay.canReplaceMapContent = YES; self.onlineOverlay.mapView = _mapView; [_mapView addOverlay:self.onlineOverlay level:MKOverlayLevelAboveLabels];

+1

All Articles