title: Adding an accessory view button to the MKMapView call out annotation?
body: <p>I've recently come across <a href="http://www.everydayone.com/2009/08/mapkit-annotation-with-buttons-example/" rel="noreferrer">this website</a> and I've been trying to add to my call out view a button (from a image).</p>
  
  <p>The code on the websites example works just fine, but when I tried to add in the same code to my project I'm not getting the same results.</p>
  
  <p>There is obviously something I've missed but I cannot seem to work this one out!</p>
  
  <p>Here is my code for annotating:</p>
  
  <pre><code>- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;) annotation{
      MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
      annView.pinColor = MKPinAnnotationColorGreen;
  
      UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeCustom];
      advertButton.frame = CGRectMake(0, 0, 23, 23);
      advertButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
      advertButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  
      [advertButton setImage:[UIImage imageNamed:@"button_right.png"] forState:UIControlStateNormal];
      [advertButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];
  
      annView.rightCalloutAccessoryView = advertButton;
  
      annView.animatesDrop=TRUE;
      annView.canShowCallout = YES;
      annView.calloutOffset = CGPointMake(-5, 5);
      return annView;
  }
  </code></pre>
  
  <p>Any help would be appreciated! :)</p>