【发布时间】:2012-02-03 16:52:17
【问题描述】:
我想在当前用户位置标注中添加一个右附件按钮。我发现了一些关于该主题的问题,但它们似乎对我不起作用。这是我到目前为止的代码,我已经成功地将正确的附件按钮放在我的其他注释上:
- (MKAnnotationView *)mapView:(MKMapView *)_mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
//TODO: this doesn't seem to be working?
if ([annotation isKindOfClass:[MKUserLocation class]]) {
MKAnnotationView * aV = [mapView viewForAnnotation:annotation];
aV.canShowCallout = YES;
aV.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
return nil;
}
return nil;
}
我在几个地方读到解决方案是为用户位置制作自定义 MKAnnotationView,但我还没有看到如何为用户位置完成此操作的演示——我已经成功地为我地图上的其他注释。
示例代码将是最有帮助的,谢谢!
【问题讨论】:
标签: ios gps mkmapview mkannotation mkannotationview