So I've tried this-
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
[self.mapAnnotationViewController.view removeFromSuperview];
MyLocation* location = (MyLocation*)view.annotation;
currentResultDictionary = [location cardJson];
[self.mapAnnotationViewController setAnnotationTitle: [location title]];
[self.mapAnnotationViewController setRating:3.0];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage* forwardButtonImage = [UIImage imageNamed:@"forward-50x50.png"];
button.frame = CGRectMake(141,5,25,25);
[button setBackgroundImage:forwardButtonImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(displayCard:) forControlEvents:UIControlEventTouchUpInside];
//Since we are re-using the callout view,
//may need to do additional "cleanup" so that the callout
//shows the new annotation's data.
[view addSubview:self.mapAnnotationViewController.view];
[view addSubview: button];
}
-(IBAction)displayCard:(id)sender{
NSLog(@"DISPLAY CARD CALLED");
}
This adds the button successfully, but when I click on it, the displayCard method is not being called. Why is that happening?
So this is probably why it's not working -
How To add custom View in map's Annotation's Callout's
However, that solution subclasses the view - I only have access to the controller. Can I reduce my problem to be solved by that solution?