gpt4 book ai didi

ios - 如何在不取消选择注释的情况下更新标注 View ?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:42:26 24 4
gpt4 key购买 nike

到目前为止,我发现更新已经可见的标注气泡中的文本的唯一方法是取消选择其注释,然后再次选择它,如下所示:

id <MKAnnotation> annotation = self.selectedAnnotation; // Keep a reference
[self.mapView deselectAnnotation:self.selectedAnnotation animated:NO];
[self.mapView selectAnnotation:annotation animated:NO];

但是,这种方法会在我的应用中产生一些不需要的副作用。

有谁知道有其他方法可以做到这一点吗?

最佳答案

Anna 在评论中为我的问题提供了完美的解决方案!

通过显式通知 MKMapView(通过 KVO 监听更改)文本更改,我设法让标注更新,否则它不会。这是工作代码:

[annotation willChangeValueForKey:@"subtitle"];
annotation.subTitle = @"New subtitle";
// subTitle is the property behind MKAnnotation's subtitle
[annotation didChangeValueForKey:@"subtitle"];

谢谢 Anna 的救助 =)

关于ios - 如何在不取消选择注释的情况下更新标注 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25640314/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com