到目前为止,我发现在已经可见的标注气泡中更新文本的唯一方法是取消选择其注释,然后再次选择它,如下所示:
id <MKAnnotation> annotation = self.selectedAnnotation; // Keep a reference
[self.mapView deselectAnnotation:self.selectedAnnotation animated:NO];
[self.mapView selectAnnotation:annotation animated:NO];
然而,这种方法会在我的应用中造成一些不必要的副作用。
有谁知道有任何其他方法可以实现这一目标?
答案 0 :(得分:4)
Anna在我的问题评论中提供了一个完美的解决方案!
通过显式通知MKMapView(通过KVO侦听更改)文本更改,我设法让callout更新,否则不会。这是工作代码:
[annotation willChangeValueForKey:@"subtitle"];
annotation.subTitle = @"New subtitle";
// subTitle is the property behind MKAnnotation's subtitle
[annotation didChangeValueForKey:@"subtitle"];
感谢安娜前来救援=)