当我的视线消失时,我收到以下消息:
An instance 0x1c11e0 of class MKAnnotationView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:
(上下文:0x0,属性:0x1e98d0>)
定义和启动反向地理编码的代码是:
geo=[[MKReverseGeocoder alloc] initWithCoordinate:droppedAt];
geo.delegate=self;
[geo start];
在我关闭视图之前,我尝试将 geo.delegate 设置为 nil。那太简单了。我也试过:
for (id <MKAnnotation> annotation in mvMap.annotations) {
[[mvMap viewForAnnotation:annotation] removeObserver:self forKeyPath:@"selected"];
}
这会引发一个错误,上面写着:
*由于未捕获的异常“NSRangeException”而终止应用程序,原因:“无法删除“选择”的关键路径的观察者,因为它没有注册为观察者。
我对注释代码的看法是:
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
MKAnnotationView *aView;
aView=(MKAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:annotation.title];
if (aView==nil)
aView=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotation.title] autorelease];
else
aView.annotation=annotation;
[aView setImage:[UIImage imageNamed:selIcon]];
aView.canShowCallout=TRUE;
aView.draggable=YES;
return aView;
}
我在旋转时在这里按下按钮和翻转开关。知道我可以在这里做什么吗?