How to move a MKAnnotation without adding/removing it from the map?

前端 未结 11 1172
情深已故
情深已故 2020-12-13 06:22

Is it possible to move the coordinate of a MKAnnotation without adding and removing the annotation from the map?

11条回答
  •  清歌不尽
    2020-12-13 06:56

    It doesn't seem possible to change the coordinate of a MKAnnotation object and then inform the MKMapView of the change.

    However, removing the previous annotation from the map, changing the coordinate of your annotation object and adding it back to the map works well.

    [theMapView removeAnnotation:myAnnotation]; 
    [myAnnotation setLatitude:newLatitude];
    [theMapView addAnnotation:myAnnotation];
    

    Why don't you want to do it this way?

提交回复
热议问题