iOS refresh annotations on mapview

后端 未结 7 1603
悲&欢浪女
悲&欢浪女 2021-01-02 10:01

I have a mapview where the annotation\'s coordinates are constantly being updated but when I use setCoordinate, the annotation does not move. How do I refresh the annotation

7条回答
  •  一整个雨季
    2021-01-02 10:39

    Swift 3.0 version of Nathan's answer (thank you Nathan):

    DispatchQueue.main.async {
        mapView.addAnnotation(annotation)
    }
    

    Side note, Nathan's answer should have far more upvotes. I actually needed this help with removing an annotation, the same issue exists and is fixed by dispatching the update to the main queue.

提交回复
热议问题