問題描述
現在我想在我的 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.
在Apple文檔中,據說
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.
我已經閱讀了一些來自 Internet 的教程和來自 Apple 的官方文檔.而且我仍然不知道何時調用此方法.
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 >)annotation
被調用.看看截圖吧.
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
附:在 addAnnotation
調用和 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation
處放置斷點,您將看到函數的流程輕松調用.
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.
這篇關于在這種情況下 mapView:viewForAnnotation: 會被調用嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!