ios - MKPolylineView initWithPolyLine : is deprecated in iOS 7

标签 ios mkmapview mapkit deprecated mkpolyline

我收到以下错误:initWithPolyline: is deprecated: first deprecated in iOS 7.0

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

instead of this 的替换方法是什么?

最佳答案

您应该使用(MKOverlayRenderer *) 类型委托(delegate)而不是(MKOverlayView *) 类型委托(delegate)。并返回 MKPolylineRenderer 而不是 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;
}

关于ios - MKPolylineView initWithPolyLine : is deprecated in iOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28276383/

相关文章:

ios - Swift:在等待信号量时显示 UIAlert

ios - PFObject 的 saveInBackgroundWithBlock : method - the block doesn't get called

c# - Xamarin.iOS 上的 MakeGenericMethod/MakeGenericType

ios - 如何在不使用属性的情况下设置 MKMapView map 类型?

ios - Swift 4 MKMapView 像 GoogleMap 一样改变 map 样式

ios - UITableViewCell 中点击的 MKMapView 的详细信息

iOS 应用程序位置权限目前无法正常工作

ios - 需要一些关于 CoreText 和 sqlite 的建议

json - 添加注释会导致在展开可选值时意外发现 nil

ios - 注释引脚颜色和类型