セグメントのボタンを表示しています。インデックス「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 にいくつかのオーバーレイが含まれていることを示しています。誰か助けてもらえますか?