問題描述
現(xiàn)在我想在我的 iOS 應(yīng)用中的地圖上添加靜態(tài)圖釘注釋.
Now I want to add a static pin annotation on map in my iOS app.
但我只想知道是否會(huì)調(diào)用委托方法 mapView:viewForAnnotation:.
But I just want to know if the delegate method mapView:viewForAnnotation: will be called.
在Apple文檔中,據(jù)說
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.
我已經(jīng)閱讀了一些來自 Internet 的教程和來自 Apple 的官方文檔.而且我仍然不知道何時(shí)調(diào)用此方法.
I have read several tutorials from Internet and official documentation from Apple. And I still don't when this method will be called.
推薦答案
每當(dāng)你調(diào)用 addAnnotation
方法 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation >)annotation
被調(diào)用.看看截圖吧.
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
調(diào)用和 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation
處放置斷點(diǎn),您將看到函數(shù)的流程輕松調(diào)用.
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.
這篇關(guān)于在這種情況下 mapView:viewForAnnotation: 會(huì)被調(diào)用嗎?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!