Adding an accessory view button to the MKMapView call out annotation?

后端 未结 3 1000
甜味超标
甜味超标 2021-02-14 15:25

I\'ve recently come across this website and I\'ve been trying to add to my call out view a button (from a image).

The code on the websites example works just fine, but w

相关标签:
3条回答
  • 2021-02-14 16:04

    Instead of setting the target like you did here:

    [advertButton addTarget:self action:@selector(showLinks:) forControlEvents:UIControlEventTouchUpInside];
    

    You can use the default delegate:

    - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
    
    0 讨论(0)
  • 2021-02-14 16:17

    Sorry to answer my own question but this was solved by setting the delegate of the MKMapView to the ViewController. Phew, took me a while to figure that out and it's so simple!!

    0 讨论(0)
  • 2021-02-14 16:25

    That guy is using a custom image to imitate the detail disclosure. You can actually get the standard detail disclosure quite easily:

    [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    
    0 讨论(0)
提交回复
热议问题