从地图视图中删除注释时出现问题
我将添加的所有注释存储在单独的数组中。当我尝试使用以下代码删除已添加到 mapView 的注释时:
if(![newClusters containsObject:cluster]){
[__mapView removeAnnotations:[__clusterAnnotations objectAtIndex:[__clusters indexOfObject:cluster]]];
[__clusterAnnotations removeObjectAtIndex:[__clusters indexOfObject:cluster]];
[__clusters removeObject:cluster];
}
我收到以下错误:
-[ClusterAnnotationClass countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance
我不确定这意味着什么,我可以添加任何注释。从地图视图中删除时会崩溃。
任何帮助将不胜感激。
I am storing all the annotations I am adding in a separate array. When I try to remove an annotation that has been added to the mapView using the following code:
if(![newClusters containsObject:cluster]){
[__mapView removeAnnotations:[__clusterAnnotations objectAtIndex:[__clusters indexOfObject:cluster]]];
[__clusterAnnotations removeObjectAtIndex:[__clusters indexOfObject:cluster]];
[__clusters removeObject:cluster];
}
I get the following error:
-[ClusterAnnotationClass countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance
I'm not sure what this means, and I can add in any annotation just fine. It crashes when removing from the mapView.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在调用
removeAnnotations
(复数),它接受一个注释数组,但看起来您传递的对象不是一个数组。也许您想调用
removeAnnotation
(单数)?You are calling
removeAnnotations
(plural) which takes an array of annotations but it looks like the object you are passing it is not an array.Perhaps you meant to call
removeAnnotation
(singular)?