viewForOverlay 从未被调用
我可以查看分段的按钮。单击索引为“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 包含一些叠加层。 有人可以帮助我吗?
I have view with segment's buttons. on clicking on button with index "1", it should show mapview with some overlays. For this reason, I have the following code:
{
[_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];
}
but the viewForOverlay method is never called =(.
NSLog shows me that mkmapview contain some overlays.
Can anybody help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在方法
-(void)drawTheMap
中,而不是[_routeMap addOverlay:dot];
尝试[self addOverlay:dot];
In the method
-(void)drawTheMap
, instead of[_routeMap addOverlay:dot];
try[self addOverlay:dot];