MKPolylineView initWithPolyLine: deprecated in iOS 7

I get the following error: initWithPolyline : deprecated: deprecated first in iOS 7.0

 MKPolylineView *lineView = [[MKPolylineView alloc] initWithPolyline:overlay]; 

What is the replacement method instead?

+7
ios deprecated mapkit mkmapview mkpolyline
source share
3 answers

See the documentation for initWithPolyline: Read the retirement statement, which says you should use the MKPolylineRenderer object MKPolylineRenderer .

+5
source share

You should use a delegate (MKOverlayRenderer *) instead of a delegate of type (MKOverlayView *) . And return MKPolylineRenderer instead of MKPolylineView .

 -(MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay { MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithOverlay:overlay]; renderer.strokeColor = [UIColor redColor]; renderer.lineWidth = 5.0; return renderer; } 
+10
source share

You will love MKPolylineRenderer , in particular, -initWithPolyline (available in iOS 7 and later).

+1
source share

All Articles