自定义注解视图,就像yelp应用程序一样,有很多细节。Yelp
有没有像截图那样定制注解视图的教程?
请帮帮忙。
发布于 2011-08-29 20:11:42
最近,我不得不使用MKMapView开发了一个使用自定义标注(注解)的应用程序。如果你想对MKAnnotationView进行大量的定制,你将无法实现它的子类化。
对我帮助最大的是那些教程:
入门教程:http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial
第1部分:http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/
第2部分:http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-2/ (还处理标注中的按钮)
发布于 2011-08-29 20:12:12
尝试以下代码:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
annView.pinColor = MKPinAnnotationColorPurple;
annView.animatesDrop=TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(-5, 5);
[rightButton setImage:[UIImage imageNamed:@"demo_img.jpg"] forState:UIControlStateNormal];
annView.leftCalloutAccessoryView=rightButton;//add image on mapView
return annView;
}https://stackoverflow.com/questions/7229841
复制相似问题