L'ajout d'un accessoire sur le bouton view pour la MKMapView appel d'annotation?

J'ai récemment rencontré ce site internet et j'ai essayé de l'ajouter à mon appel de la vue sur un bouton (à partir d'une image).

Le code sur les sites web exemple fonctionne très bien, mais quand j'ai essayé d'ajouter dans le même code pour mon projet, je n'obtiens pas les mêmes résultats.

Il y a évidemment quelque chose que j'ai raté mais je n'arrive pas à faire ce travail!

Voici mon code pour l'annotation:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    annView.pinColor = MKPinAnnotationColorGreen;

    UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeCustom];
    advertButton.frame = CGRectMake(0, 0, 23, 23);
    advertButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    advertButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

    [advertButton setImage:[UIImage imageNamed:@"button_right.png"] forState:UIControlStateNormal];
    [advertButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];

    annView.rightCalloutAccessoryView = advertButton;

    annView.animatesDrop=TRUE;
    annView.canShowCallout = YES;
    annView.calloutOffset = CGPointMake(-5, 5);
    return annView;
}

Toute aide serait appréciée! 🙂

Malheureusement, Le Lien Que Vous Avez Fourni Est Mort

OriginalL'auteur ingh.am | 2009-09-16