簡體   English   中英

在哪種情況下會調用mapView:viewForAnnotation:

[英]In which case that mapView:viewForAnnotation: will be called?

現在我想在我的iOS應用程序中在地圖上添加靜態引腳注釋。

但我只是想知道是否會調用委托方法mapView:viewForAnnotation :.

在Apple文檔中,據說

 When it needs an annotation view, the map view calls the mapView:viewForAnnotation:    method of its delegate object. 

我從互聯網和Apple的官方文檔中讀過幾個教程。 當這個方法被調用時我仍然不會。

無論何時調用addAnnotation方法- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation都會調用- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation 看看截圖。

在此輸入圖像描述

您可以在MKMapView Class Reference上找到它

PS在addAnnotation調用時放置斷點和- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation您將很容易看到函數調用的流程。

顯然MKMapView至少會調用mapView:viewForAnnotation:當它需要將你的MKAnnotationView顯示到屏幕上時。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM