繁体   English   中英

不建议使用“ initWithPolygon:”和“ initWithPolyline:”:在iOS 7.0中首先不建议使用:iOS中是否有针对此警告的解决方案?

[英]'initWithPolygon:' & 'initWithPolyline:' are deprecated: first deprecated in iOS 7.0: is there any solution for this warning in iOS?

我正在使用KMLParser库进行离线地图下载,以从服务器下载.kml文件,但发现了这些警告。

请提供任何解决方案以消除这些警告。

这是两者的功能:

对于initWithPolygon,

- (MKOverlayPathView *)createOverlayView:(MKShape *)shape
{
    // KMLPolygon corresponds to MKPolygonView

    MKPolygonView *polyView = [[MKPolygonView alloc] initWithPolygon:(MKPolygon *)shape];
    return polyView ;
}

对于initWithPolyline,

- (MKOverlayPathView *)createOverlayView:(MKShape *)shape
{
    // KMLLineString corresponds to MKPolylineView
    MKPolylineView *lineView = [[MKPolylineView alloc] initWithPolyline:(MKPolyline *)shape];
    return lineView ;
}

您应该使用(MKOverlayRenderer *)类型委托,而不是(MKOverlayView *)类型委托。 然后返回MKPolylineRenderer而不是MKPolylineView

- (MKOverlayRenderer *)mapView:(MKMapView *)mapView
           rendererForOverlay:(id<MKOverlay>)overlay {
   MKPolylineRenderer *renderer = [[MKPolylineRenderer alloc] initWithOverlay:overlay];
   renderer.strokeColor = [UIColor blueColor];
   renderer.lineWidth = 2.0;            
   return renderer;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM