I want to add an annotation to a MapView with disclosure button on it and I can't figure it out.
I have created a PlaceMark class that conforms to the MKAnnotation protocol and then create the MapView and add the PlaceMark:
// 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];
This all works and a pin is displayed that when touched displays the correct call out text. I cannot figure out how to add a disclosure button to the call out. Sorry if this is elementary and any help would be appreciated.
Dave
Think I've figured it out... Implemented the following delegate method:
- (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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With