问题描述
当我尝试在我的MKMapView中移动MKCircle时,我收到以下错误消息: - [MKCircle setCoordinate:]无法识别的选择器..
。但根据文档,MKCircle符合MKAnnotation协议,因此它应该实现 setCoordinate:
方法(此外Xcode为我提供了自动提示,而调试器没有显示任何警告)。
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?
非常感谢。
推荐答案
尽管MKCircle确实符合MKAnnotation,但MKCircle类(不幸的是)将坐标属性覆盖为只读:
Even though MKCircle does conform to MKAnnotation, the MKCircle class then (unfortunately) overrides the coordinate property as read-only:
@property(非原子,只读)
CLLocationCoordinate2D坐标
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate
最简单的解决方案是使用 removeOverlay:
删除旧的叠加层并添加一个新的叠加层新的中心坐标和半径。
The simplest solution is to remove the old overlay with removeOverlay:
and add a new one with the new center coordinate and radius.
这篇关于在MKMapView中移动MKCircle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!