开发者

iphone programming objective-c : mkannotation Pin problem

i tryed to make a customized pin on the map with green color and with a button. but it doesnt work. I have a class named Placemark that implement mkannotation protocol. This is my method that supposed to show a green pin but it doesnt:

- (MKAnnotationView *) map:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] in开发者_JAVA技巧itWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    annView.pinColor = MKPinAnnotationColorGreen;
    annView.animatesDrop=TRUE;
    annView.canShowCallout = YES;
    annView.calloutOffset = CGPointMake(-5, 5);
    return annView;
}

i also want to specified that my MKMapview is called "map" and its an IBOutlet.

thanks


The method name must be mapView:viewForAnnotation:. The map view looks specifically for that name. You can change the internal parameter variable names but not the parts before the colons.

Try this:

- (MKAnnotationView *) mapView:(MKMapView *)map 
                            viewForAnnotation:(id <MKAnnotation>) annotation

With that misspelling, the map view doesn't call your viewForAnnotation method and must be putting a default red pin on the map.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜