0

我可以将 PlaceMark 放置在 MapView 上,但是我必须单击图钉才能看到标题出现。我想要的是默认显示的标题。

到目前为止,这是我的代码:

  [self.mapView setRegion:adjustedRegion animated:YES];

    PlaceMark *placeMark = [[PlaceMark alloc]
                            initWithCoordinate:self.centerOfMap
                            andMarkTitle:@"My Title"
                            andMarkSubTitle:@"Sub Title"];


    [self.mapView addAnnotation:placeMark];

还:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

    static NSString *identifier = @"MyLocation";
    if ([annotation isKindOfClass:[PlaceMark class]]) {

        MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
        if (annotationView == nil) {
            annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
        } else {
            annotationView.annotation = annotation;
        }

        annotationView.enabled = YES;
        annotationView.canShowCallout = YES;

        return annotationView;
    }

    return nil; 
}
4

1 回答 1

0

请看一下覆盖委托。

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 
{


}
于 2012-09-29T17:00:24.040 回答