how to detect a callout of an annotation is showin

2020-07-11 05:01发布

问题:

I have a checkin related app. When user clicks a venue on map, callout will popup and show its name and address. At the same time, if the venue is within 1000m from current location, a check in button will be displayed.

To a venue that can checkin, all I want is,

when callout is popup, check in button shows. when callout is disappear, that button disappears too.

Now show button works well, but I don't know how to detect callout visible status. Is there any callback method that callout show/hide?

Thanks in advance!

回答1:

Callout appears when annotation is selected - you can use mapView:didSelectAnnotationView: method in delegate to track that event. Callout hides when annotation is deselected - use mapView:didDeselectAnnotationView: method to track that event.



回答2:

As you can see here it is about selected property of MKAnnotationView, which is saying that If the property contains YES, the annotation view is displaying a callout bubble.

You may additionally implement an observer for this property, to implement your functionality.