Search code examples
iosiphoneuikitmkmapviewmkannotation

How to register tapgesture on MKAnnotationView image?


Is there a way to register tapgesture within the image of MKAnnotationView ?

Basically my anotation view looks like this, it has no title, no subtitle, only custom image, and I would like to stay it that way if possible:

My current test MKAnnotationView

I would like to navigate to a different viewcontroller when tapped inside the image or show a TableView from the bottom of the screen. For now I really just need to see how to register tapped gesture inside so I can move forward with the functionality.

Cheers.


Solution

  • You can use didSelect method.

    e.g.

    func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
        // navigate to a different viewcontroller
        //   or show a TableView from the bottom of the screen
    }