Question

Je veux ajouter une annotation à un MapView avec bouton d'information à ce sujet et je ne peux pas le comprendre.

J'ai créé une classe Placemark qui est conforme au protocole MKAnnotation puis créer le MapView et ajoutez le repère:

// Add annotation information
PlaceMark *venuePlacemark = [[PlaceMark alloc] initWithCoordinate:location];
venuePlacemark.locationTitle = [locationDictionary valueForKey:VENUE_NAME_KEY];
venuePlacemark.locationSubtitle = @"Touch to show in Google Maps";

// Create the accessory button on the placemark
[venueMap addAnnotation:venuePlacemark];
[venueMap setRegion:region animated:TRUE];
[venueMap regionThatFits:region];

tous les travaux et une broche est affiché que quand on les touche affiche l'appel correct sur le texte. Je ne peux pas comprendre comment ajouter un bouton d'information à l'appel à. Désolé si cela est élémentaire et toute aide serait appréciée.

Dave

Était-ce utile?

La solution

pense que j'ai pensé à elle ... Mis en œuvre la méthode déléguée suivante:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *dropPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"venues"];

    UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [disclosureButton addTarget:self action:@selector(mapCallOutPressed:) forControlEvents:UIControlEventTouchUpInside];

    dropPin.rightCalloutAccessoryView = disclosureButton;
    dropPin.animatesDrop = YES;
    dropPin.canShowCallout = YES;

    return dropPin;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top