Add overlays
myPolygon=[MKPolygon polygonWithCoordinates:points count:numberOfPoints];
[self.mapView addOverlay:myPolygon];
remove overlay
[self.mapView removeOverlay:myPolygon];
由于
答案 0 :(得分:0)
当你调用removeOverlays:时,地图视图将释放MKOverlay和MKOverlayView对象。
您在myPolygon中拥有自己的引用。
if (myPolygon != nil) {
[myPolygon release]; // <-- remove this
myPolygon = nil;
}
if (myPolygon != nil) {
[myPolygon release]; // <-- remove this
myPolygon = nil;
}
OR
for (id<MKOverlay> overlayToRemove in mapView.overlays)
{
if ([myPolygon isKindOfClass:[OverlayClassToRemove class]])
{
[mapView removeOverlay:myPolygon];
}
}