【发布时间】:2010-11-20 12:42:02
【问题描述】:
MapKit 似乎有一个奇怪的问题!!!
我有一些代码添加了一些注释,然后我调用了
NSArray *existingpoints = mapView.annotations;
[mapView removeAnnotations:existingpoints];
if ([mapView.annotations count] > 0) {
for(Plane *annotation in mapView.annotations){
NSLog(@"Name: %@",annotation.reg);
[mapView removeAnnotation:annotation];
}
NSLog(@"\nMapCount:%i after attempting manual remove",[mapView.annotations count]);
}
现在奇怪的是,有时我可以进入 mapView.annotations 计数大于 0。因此我有额外的“保护”并尝试手动删除该项目而不是 NSLogged。
不过最终的计数还是 1!
最奇怪的!
【问题讨论】:
-
不确定这是否会导致这种情况,但您是否打开了showsUserLocation?
-
不,在这个例子中我没有。我做到了,那是我的第一个停靠港!
-
在调试器中检查剩余的注解会发生什么?查看剩余的对象及其内容。
-
奇怪的是,它是一个有效的对象,并且具有所有属性。它甚至显示在地图上,我可以与之互动!
标签: iphone mapkit mkmapview mkannotation mkannotationview