如果我創建一個地圖視圖的視圖控制器,這是我加入到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)放入視圖中。
之前有人遇到過這個錯誤,或者甚至更好地知道如何解決它?
這不是一個錯誤,它是一個功能! :) – elp
聽起來像一個bug給我。我的直覺是,當它可見時,地圖保留一段時間(爲了做一個動畫淡出?),隱藏錯誤。 –
@paska如果它是一個非常惱人的功能:) –