In which case that mapView:viewForAnnotation: will be called?

前端 未结 2 1465
时光说笑
时光说笑 2020-12-18 08:25

Now I want to add a static pin annotation on map in my iOS app.

But I just want to know if the delegate method mapView:viewForAnnotation: will be called.

In

相关标签:
2条回答
  • 2020-12-18 08:37

    Obviously MKMapView at least will call mapView:viewForAnnotation: when it will need to display your MKAnnotationView to the screen.

    0 讨论(0)
  • 2020-12-18 08:47

    Whenever you call addAnnotation method - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation gets called. Have look at the screenshot.

    enter image description here

    You can find this on MKMapView Class Reference

    P.S. Put breakpoints at addAnnotation call and - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation you will see the flow of function call easily.

    0 讨论(0)
提交回复
热议问题