我在mapkit中显示了一个带有自定义图像的注释,显示正常,
但是在录制针脚后显示注释
当我启动视图时,如何在默认情况下显示注释?发出针脚。
- (MKAnnotationView *)mapView:(MKMapView *)mv viewForAnnotation:(id <MKAnnotation>)annotation
{
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
NSString *annotationIdentifier = @"PinViewAnnotation";
MKPinAnnotationView *pinView = (MKPinAnnotationView *) [mapView
dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
pinView = [[[MKPinAnnotationView alloc]
initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
[pinView setPinColor:MKPinAnnotationColorGreen];
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
UIImageView *houseIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tijereta.png"]];
pinView.leftCalloutAccessoryView = houseIconView;
[houseIconView release];
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
感谢
答案 0 :(得分:35)
你可以用这个
[mapView selectAnnotation:pinView animated:YES];
//这里pinView是你的注释,mapview是你的地图
希望有所帮助