MKMapView调用didSelectAnnotationView

我使用MKMapView 。 在地图上,我显示可点击的AnnotationViews 。 点击AnnotationView ,我将MyController推送到NavigationController 。 在MyController中,我点击后退button,之后我的前一个控制器显示(做popup控制器)。 当我点击我previousControllercallback中的AnnotationVIew didSelectAnnotationView不会rased。 为什么发生?

这是因为当我点击注释时select了注释,当我再次单击这个注释时,它不会调用callbackdidSelectAnnotationView ,因为这个注释已经被选中了。

检查是否在.h文件中添加了MKMapViewDelegate,并在.m文件中放置了委托

  mapView.delegate = self; 

而如果它不起作用检查didSelectAnnotationView是否正确书写或不。

Swift 2.1:

通过Apple文档(按Cmd +点击课程名称):

 // Select or deselect a given annotation. Asks the delegate for the corresponding annotation view if necessary. public func selectAnnotation(annotation: MKAnnotation, animated: Bool) public func deselectAnnotation(annotation: MKAnnotation?, animated: Bool) public var selectedAnnotations: [MKAnnotation] 

因此在对所选注释调用执行所有操作之后

 self.yourMapView.deselectAnnotation(yourAnnotation, animated: true) 

正如Oksana所说:这是因为注释视图被选中,你应该取消select它。

你可以使用: [_mapView selectAnnotation:nil animated:NO];

一旦我们点击注释,它会打电话

 - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view 

在点击标注之外点击它应该触发

 - (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view 

但在我的情况下,我重写了外部注释点击,所以我打电话方式编程的地方需要:

 [geoMapView deselectAnnotation:nil animated:NO];