ios - 更改 map 中心后标注在错误位置打开

标签 ios swift mapkit

当用户从表格中选择一个项目时,我将 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/

相关文章:

iphone - 提交到 AppStore 后重命名 iOS App

iOS - UITableView 的 UIRefreshControl 与 UITableViewController 的 UIRefreshControl

ios - 是否可以同时填充两个数组?

javascript - 如何使用 Emscripten 将 Hello Word 从 Swift 编译为 JavaScript

swift - 如何在同一区域附近设置多个注释

Swift 4 MapKit 检查标记是否靠近我的位置

ios - Xcode for iOS 项目的动态分析器和静态分析器有什么区别?

ios - 在 Swift 中存储数组并从数组中获取数据

ios - 根据用户航向更新 iOS map

java - Android Xml 检查 web 服务是否返回 true 或 false