当用户从表格中选择一个项目时,我将 map 的中心更改为所选项目的位置,并以编程方式选择匹配的注释。这会导致标注标注在 map 上打开。
mapView.centerCoordinate = itemCoordinate
mapView.selectAnnotation(itemAnnotation, animated: true)
我的问题是callout是在 map 之前的地方打开的,好像是先打开callout然后 map 移动(没有移动callout)
有什么解决办法吗?
最佳答案
您可以尝试在像这样的小延迟后选择注释:
let dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(dispatchTime, dispatch_get_main_queue()) { () -> Void in
mapView.selectAnnotation(itemAnnotation, animated: true)
}
或者选择没有动画的注释也应该有效:
mapView.selectAnnotation(itemAnnotation, animated: false)
关于ios - 更改 map 中心后标注在错误位置打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30031618/