I dont want pin to be call directly on map, I want this on button action to call pin annotation.
When I call this method on button click event my app was crash. I want to call annotation on button click. Can I call this all method on button?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *pin = (MKPinAnnotationView *) [self.map dequeueReusableAnnotationViewWithIdentifier: @"restMap"];
if (pin == nil) {
pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"restMap"] autorelease];
} else {
pin.annotation = annotation;
}
pin.pinColor = MKPinAnnotationColorRed
pin.canShowCallout = YES;
pin.animatesDrop = NO;
UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.annotations indexOfObject:annotation];
detailButton.tag = annotationValue;
[detailButton addTarget:self action:@selector(showDetailView:) forControlEvents:UIControlEventTouchUpInside];
pin.rightCalloutAccessoryView = detailButton;
return pin;
}