2011-07-24 48 views
6

如果我创建一个地图视图的视图控制器,这是我加入到viewDidLoad中的唯一代码:可能的错误

MKPointAnnotation* annotation = [[MKPointAnnotation alloc] init]; 
annotation.coordinate = CLLocationCoordinate2DMake(-90, -180); 
[self.mapView addAnnotation:annotation]; 
[self.mapView removeAnnotation:annotation]; 
[annotation release]; 

我得到的错误:

An instance 0xa126fa0 of class MKPointAnnotation 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: 
<NSKeyValueObservationInfo 0xa127df0> (
<NSKeyValueObservance 0xa127c90: Observer: 0xa11c530, Key path: coordinate, Options: <New: NO, Old: NO, Prior: YES> Context: 0x0, Property: 0xa127640> 

如果我改变码到这个话,我没有得到任何错误:

MKPointAnnotation* annotation = [[MKPointAnnotation alloc] init]; 
annotation.coordinate = CLLocationCoordinate2DMake(0, 0); 
[self.mapView addAnnotation:annotation]; 
[self.mapView removeAnnotation:annotation]; 
[annotation release]; 

唯一的区别是,(0,0)在地图上,可见一个地方s,(-90,-180)不在视野内。也就是说,我需要平移地图以将坐标(-90,-180)放入视图中。

之前有人遇到过这个错误,或者甚至更好地知道如何解决它?

+2

这不是一个错误,它是一个功能! :) – elp

+0

听起来像一个bug给我。我的直觉是,当它可见时,地图保留一段时间(为了做一个动画淡出?),隐藏错误。 –

+1

@paska如果它是一个非常恼人的功能:) –

回答

5

经过一些更多的测试后,我确信它是MKMapView中的一个错误。我只是通过添加可见区域中的注释来解决这个问题。更多的工作,但至少它不会崩溃我的应用程序:)

+1

通常,当我编程时,我几乎总是排除SDK或底层操作系统的问题,无论我多么肯定这个问题不是我。 我一直在寻找这个近一天的时间,在这种情况下,我可能不得不同意你的看法,认为它可能是SDK中的一个bug ... – jklp