我有段的按钮视图。单击索引为“1”的按钮时,它应该显示带有一些叠加层的地图视图。出于这个原因,我有以下代码:
{
[_routeMap setHidden:NO];
[self drawTheMap];
[_routeMap setRegion:_region animated:YES];
[_routeMap regionThatFits:_region];
[_navBar setHidden:NO];
NSLog(@"overlays: %@", _routeMap.overlays);
}
-(void)drawTheMap
{
[_routeMap setFrame:CGRectMake(0, 44, 320, 416)];
for (int i=0; i<[_arrayOfPoints count]; i++) {
CLLocation* location = [[CLLocation alloc] initWithLatitude:[[_arrayOfPoints objectAtIndex:i] latitude]
longitude:[[_arrayOfPoints objectAtIndex:i] longitude]];
...
MKCircle * dot = [MKCircle circleWithCenterCoordinate:location.coordinate radius:radius];
[_routeMap addOverlay:dot];
...
}
...
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKCircleView *circleView = [[MKCircleView alloc] initWithCircle:overlay];
circleView.lineWidth = 1.0;
circleView.strokeColor = [UIColor orangeColor];
[circleView setFillColor:[UIColor orangeColor]];
return [circleView autorelease];
}
但是 viewForOverlay 方法从未被调用 =(。NSLog 告诉我 mkmapview 包含一些覆盖。有人可以帮助我吗?