我可以将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;
}
答案 0 :(得分:0)
请看一下重叠代表。
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
}