![](/img/trans.png)
[英]mapView:viewForAnnotation: not called in iOS6, works fine in iOS7
[英]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.