0

我想在 MKMapView 上创建自定义注释和标注。我必须创建尺寸更大的注释,并且必须显示三四行文本(标签)。那么如何创建自定义注释和标注气泡。

提前致谢。

阿什什

4

2 回答 2

1

您应该只重新实现 3 种方法:

自定义您的注释使用:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation

在这里只需添加您需要的子视图

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

在这里只需从 superView 中删除您的自定义 callOutView

- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view

查看此博客了解详细信息

于 2013-07-11T14:09:44.497 回答
-2

你可以使用这个。

- (MKAnnotationView *)mapView:(MKMapView *)newMapView viewForAnnotation:(id )newAnnotation {
    MKAnnotationView *a = [ [ MKAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier:@"PinView"];

    if ( a == nil )
        a = [ [ MKAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier: @"PinView" ];

    a.image = [ UIImage imageNamed:@"Image.png" ];
    a.canShowCallout = YES;
    a.rightCalloutAccessoryView = [ UIButton buttonWithType:UIButtonTypeDetailDisclosure ];
    UIImageView *imgView = [ [ UIImageView alloc ] initWithImage:[ UIImage imageNamed:@"Image.png" ] ];
    a.leftCalloutAccessoryView = imgView;

    return a;
}
于 2012-08-27T08:36:56.860 回答