在这种情况下 mapView:viewForAnnotation: 会被调用吗?

In which case that mapView:viewForAnnotation: will be called?(在这种情况下 mapView:viewForAnnotation: 会被调用吗?)
本文介绍了在这种情况下 mapView:viewForAnnotation: 会被调用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

现在我想在我的 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: 会被调用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

iOS refresh annotations on mapview(iOS在mapview上刷新注释)
How to calculate distance from user location to annotation when user moves(用户移动时如何计算用户位置到注释的距离)
Why does a custom MKMapView annotation image disappear on touch?(为什么自定义的 MKMapView 注释图像在触摸时会消失?)
What#39;s the meaning of new @SystemApi annotation, any difference from @hide?(新的@SystemApi 注解是什么意思,和@hide 有什么区别?)
Retrofit @body with @multipart having Issue(使用 @multipart 改造 @body 有问题)
iPhone Map Kit cluster pinpoints(iPhone Map Kit 集群定位)