JavaEar 专注于收集分享传播有价值的技术资料

Moving MKCircle in MKMapView

when I try to move MKCircle in my MKMapView I get this error message: -[MKCircle setCoordinate:] unrecognized selector ... But according to the documentation MKCircle conforms to MKAnnotation protocol so it should have setCoordinate: method implemented (in addition Xcode offer me autosuggestion for it and debugger doesn't show any warnings).

Does anyone know where's the problem?

Thanks a lot.

1个回答

    最佳答案
  1. Even though MKCircle does conform to MKAnnotation, the MKCircle class then (unfortunately) overrides the coordinate property as read-only:

    The center point of the circular area, specified as a latitude and longitude. (read-only)

    @property (nonatomic, readonly) CLLocationCoordinate2D coordinate


    The simplest solution is to remove the old overlay with removeOverlay: and add a new one with the new center coordinate and radius.