Domanda

Voglio aggiungere un'annotazione a un MapView con pulsante di divulgazione su di esso e non riesco a capirlo.

Ho creato una classe segnaposto che è conforme al protocollo MKAnnotation e quindi creare il MapView e aggiungere il segnaposto:

// 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];

Questa tutte le opere e un perno che viene visualizzato quando viene toccato visualizza la chiamata giusta fuori testo. Non riesco a capire come aggiungere un pulsante di apertura a chiamata fuori. Scusate se questo è elementare e tutto l'aiuto sarebbe apprezzato.

Dave

È stato utile?

Soluzione

credo di aver capito ... Implementato il seguente metodo delegato:

- (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;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top