开发者

Map MKAnnotaionView Customise

Customise annotaion view just like the yelp application with lot of details. Yelp

Is there a tuiitorial to customise the annotaion view like the 开发者_开发技巧one in the screen shots?

Please help.


Try this code:

- (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;
}


Recently I had to develop an app using MKMapView using custom callouts (annotations). You won't get around subclassing MKAnnotationView if you want to do a lot of customizations to it.

What helped me most were those tutorials:

Intro Tutorial: http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial

Part 1: http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-1/

Part 2: http://blog.asolutions.com/2010/09/building-custom-map-annotation-callouts-part-2/ (Also handles buttons inside your callout)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜