我在这里失去了理智。为什么这不起作用?调用update_map方法但viewForOverlay不会。
- (void)viewDidLoad {
[super viewDidLoad];
if(mapView2 != nil)
{
[self update_map];
}
- (void)update_map
{
CLLocationDistance fenceDistance = 100000;
MKCircle *circle = [MKCircle circleWithCenterCoordinate:newCoord radius:fenceDistance];
[mapView2 addOverlay:circle];
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay
{
NSLog(@"circle overlay");
MKCircleView *circleView = [[MKCircleView alloc initWithOverlay:overlay];
[circleView setFillColor:[UIColor blueColor]];
[circleView setAlpha:0.1f];
return circleView;
}
答案 0 :(得分:0)
确保您的视图控制器支持<RKMapViewDelegate>
协议,delegate
实例的mapView2
属性设置为视图控制器,可以是.xib,也可以通过编程方式设置,如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView2.delegate = self;
}