MKPolylineView initWithPolyLine: is deprecated in iOS 7

こ雲淡風輕ζ 提交于 2019-12-08 16:37:37

问题


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 ?


回答1:


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




回答2:


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;
}



回答3:


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



来源:https://stackoverflow.com/questions/28276383/mkpolylineview-initwithpolyline-is-deprecated-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!