didAddAnnotationViews不能在MKMapView上运行 [英] didAddAnnotationViews not working on MKMapView

查看:337
本文介绍了didAddAnnotationViews不能在MKMapView上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在玩MKMapView并尝试了解MKMapViewDelegate系统的工作原理。到目前为止,我没有运气来添加当前位置标记时调用didAddAnnotationViews。

I've been playing around with the MKMapView and trying get my head around how the MKMapViewDelegate system works. So far I have no luck in getting the didAddAnnotationViews to get called when the current location marker is added.

我设置了我的app委托以实现MKMapViewDelegate,我有一个Outlet到我的xib中的MapView并将MapView的delegate属性设置为self,就像在app delegate实例中一样。我在app委托中实现了didAddAnnotationViews,我只需要对它进行NSLog任何调用,如下所示。地图设置为显示它所做的当前位置,并在启动时添加蓝色针注释,但由于某种原因,没有命中didAddAnnotationViews。

I have set my app delegate to implement MKMapViewDelegate, I have an Outlet to the MapView in my xib and have set the delegate property of the MapView to be self, as in the app delegate instance. I have implemented didAddAnnotationViews in the app delegate which I simply NSLog any calls to it as shown below. The map is set to show current location which it does and adds the blue pin annotation on startup, but for some reason didAddAnnotationViews is not being hit.

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views{
    NSLog(@"Annotation added!");
}

我可能错过了哪些想法?

Any ideas what I might have missed?

推荐答案

mapView:didAddAnnotations:仅在响应 addAnnotation时被调用: addAnnotations:。用户位置引脚不会触发此委托方法。

mapView:didAddAnnotations: is only called in response to addAnnotation: or addAnnotations:. The users location pin will not trigger this delegate method.

这篇关于didAddAnnotationViews不能在MKMapView上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆