MKPolylineView initWithPolyLine: is deprecated in iOS 7
Asked Answered
D

3

8

I am getting the following error: initWithPolyline: is deprecated: first deprecated in iOS 7.0

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

What is the replacement method of instead of this ?

Deucalion answered 2/2, 2015 at 11:7 Comment(1)
Use MKPolylineRenderer as the answer says but you also need to implement the rendererForOverlay delegate method instead of viewForOverlay.Wylie
C
5

See the documentation for initWithPolyline:. Read the Deprecation Statement which says to use an MKPolylineRenderer object instead.

Curst answered 2/2, 2015 at 16:50 Comment(0)
B
11

You should use (MKOverlayRenderer *) type delegate instead of (MKOverlayView *) type delegate. 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;
}
Bilingual answered 30/1, 2016 at 14:59 Comment(0)
C
5

See the documentation for initWithPolyline:. Read the Deprecation Statement which says to use an MKPolylineRenderer object instead.

Curst answered 2/2, 2015 at 16:50 Comment(0)
W
1

You will like to take a look to MKPolylineRenderer, specifically to -initWithPolyline (avalilable in iOS 7 and later).

Wolsey answered 2/2, 2015 at 12:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.