在这种情况下该图形页面:viewForAnnotation:会叫什么名字? [英] In which case that mapView:viewForAnnotation: will be called?
问题描述
现在我想添加地图的静态销标注在我的iOS应用程序。
Now I want to add a static pin annotation on map in my iOS app.
但我只是想知道,如果委托方法的MapView:viewForAnnotation:将被称为
But I just want to know if the delegate method mapView:viewForAnnotation: will be called.
在苹果的文档,它是说,
In the Apple documentation, it is said that
When it needs an annotation view, the map view calls the mapView:viewForAnnotation: method of its delegate object.
我已经阅读从苹果互联网和官方文件的几个教程。
我仍然没有当这个方法会被调用。
I have read several tutorials from Internet and official documentation from Apple. And I still don't when this method will be called.
推荐答案
当你调用 addAnnotation
方法 - (MKAnnotationView *)的MapView:(的MKMapView *)的MapView viewForAnnotation:(ID< MKAnnotation>)注释
被调用。已经看截图。
Whenever you call addAnnotation
method - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation
gets called. Have look at the screenshot.
您可以找到这个在 MKMapView类参考
You can find this on MKMapView Class Reference
P.S。把断点在 addAnnotation
通话和 - (MKAnnotationView *)的MapView:(的MKMapView *)的MapView viewForAnnotation:(ID&LT; MKAnnotation&GT;)注释
,你会很容易地看到函数调用的流程。
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.
这篇关于在这种情况下该图形页面:viewForAnnotation:会叫什么名字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!