【发布时间】:2018-06-05 08:58:20
【问题描述】:
我使用 API 中的坐标在地图上添加了注释,但它没有显示出来:
- 我声明了一个不是来自 API 的新坐标,可以显示在地图上。
- 可以打印坐标形式API,坐标没问题。
- 我将 mapView.addAnnotation() 放在 DispatchQueue.main.async 中。
谁能告诉我如何解决它?谢谢! 这是我的代码:
extension LocationViewController: ParkProviderDelegate {
func didFetch(by provider: ParkProvider) {
DispatchQueue.main.async {
let annotation = MKPointAnnotation()
let coordinate = self.provider.parks[0].coordinate
self.mapView?.addAnnotation(annotation)
}
}
【问题讨论】:
-
设置
annotation.coordinate = coordinate