Moving MKCircle in MKMapView

2019-02-17 09:18发布

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条回答
干净又极端
2楼-- · 2019-02-17 09:34

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.

查看更多
登录 后发表回答