MKMapView refresh after pin moves

前端 未结 7 1251
猫巷女王i
猫巷女王i 2020-12-14 23:42

A custom AnnotationView is updated with new coordinates. But the problem is that it visually updates only after some manipulations with MKMapView, e.g. zooming or moving. Wh

7条回答
  •  情话喂你
    2020-12-14 23:55

    MKMapView observes the coordinate property of annotations via KVO. You simply need to observe proper KVO protocol and send the annotation willChangeValueForKey: and didChangeValueForKey: with keypath of @"coordinate" before and after you update the coordinates.

    Likewise title and subtitle are also observed by MKMapView. so if you update those and want the value in the callout to change automatically without any effort on your part, just do the same: call willChangeValueForKey: and didChangeValueForKey:

提交回复
热议问题