Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKPolylineView initWithPolyLine: is deprecated in iOS 7

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 ?

like image 655
IosAdvocate Avatar asked Feb 02 '15 11:02

IosAdvocate


3 Answers

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;
}
like image 148
Jin Avatar answered Oct 27 '22 08:10

Jin


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

like image 28
casillas Avatar answered Oct 27 '22 07:10

casillas


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

like image 45
Pablo Carrillo Alvarez Avatar answered Oct 27 '22 09:10

Pablo Carrillo Alvarez