I have a working extention of MKOverlayView
class with the mapview delegate triggering and executing the – mapView:viewForOverlay
: delegate method perfectly. So to move away from a deprecated class, I have changed my extention of MKOverlayView
to extend MKOverlayRenderer
... Doing this, but leaving the viewForOverlay
method in place works fine....
However the delegate method viewForOverlay
is deprecated as well, so I replace it with the rendererForOverlay
method to be in alignment with the non Deprecated API and it NEVER gets triggered...
The delegate for the MapView
is properly hooked up, (which is proven by the viewForOverlay
working, but when I replace this method with rendererForOverlay
, which is its replacement, it never ever triggers... and as such my overlay doesn't get drawn. This makes no sense to me.
I am very much at a loss, the only thing different between versions that work, and versions that don't, is this method. Even after I changed my class from being an MKOverlayView
extention to an MKOverlayRenderer
extention the overlay still draws as long as the viewForOverlay
method exists in the delegate, it gets called. But the moment I replace the viewForOverlay
delegate method for the rendererForOverlay
method nada.
Here is the code:
This method works properly whether the class MapOverlayView
is extending MKOverlayView
or MKOverlayRenderer
, either one and this delegate method is called and the overlay is rendered.
-(MKOverlayView*)mapView:(MKMapView*)mapView viewForOverlay:(id<MKOverlay>) overlay{
MyMapOverlay *mapOverlay = overlay;
MapOverlayView *mapOverlayView = [[MapOverlayView alloc] initWithOverlay:mapOverlay];
return mapOverlayView;
}
For this method I make sure MapOverlayView
is always extending MKOverlayRenderer
, but the delegate method NEVER gets triggered.. Why would the above deprecated method always get called and work, but the below proper non deprecated method never get triggered?
-(MKOverlayRenderer*)mapView:(MKMapView*)mapView rendererForOverlay:(id<MKOverlay>) overlay{
MyMapOverlay *mapOverlay = overlay;
MapOverlayView *mapOverlayView = [[MapOverlayView alloc] initWithOverlay:mapOverlay];
return mapOverlayView;
}