mapkit 默认显示注解 [英] mapkit show annotation by default
本文介绍了mapkit 默认显示注解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 mapkit 中显示了一个带有自定义图像的注释,显示正常,
I have an annotation showing in mapkit with a custom image, showing fine,
但是在点击大头针后会显示注释,
but the annotation shows after taping the pin,
如何在默认情况下显示注释?,当我启动视图时?不用敲针.
how can I have the annotation showing by default?, when I start the view? whit out tapping the pin.
- (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;
}
谢谢
推荐答案
你可以使用这个
[mapView selectAnnotation:pinView animation:YES];
//这里pinView是你的注解,mapview是你的地图
[mapView selectAnnotation:pinView animated:YES];
//here pinView is your annotation and mapview is your map
希望有所帮助
这篇关于mapkit 默认显示注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文