我加入註解註冊並有應該是在我的地圖5個註釋針腳,但只有2個出現,顯示此錯誤:實例被釋放,而鍵值觀察家仍用它
的類Annotation的實例0x9d8e720被解除分配,而值爲 的值觀察者仍在其中註冊。觀察信息是 泄漏,甚至可能被誤認爲是其他物體。 坐落在NSKVODeallocateBreak斷點停止^ h
//NUH COORDINATES
#define NUH_latitude 1.293700;
#define NUH_longitude 103.783353;
//span
#define the_span 0.002f;
//NHGP COORDINATES!
#define NHGP_latitude 1.295938;
#define NHGP_longitude 103.782857;
//NUHER COORDINATES
#define NUHER_latitude 1.294968;
#define NUHER_longitude 103.783716;
//NUCIS COORDINATES
#define NUCIS_latitude 1.293149;
#define NUCIS_longitude 103.783464;
//Viva-UCCC COORDINATES!
#define VivaUCCC_latitude 1.294099;
#define VivaUCCC_longitude 103.783233;
//span
MKCoordinateSpan span;
span.latitudeDelta = the_span;
span.longitudeDelta = the_span;
MKCoordinateRegion myRegion;
//center
CLLocationCoordinate2D center;
center.latitude = NUH_latitude;
center.longitude = NUH_longitude;
myRegion.center =center;
myRegion.span = span;
[mapview setRegion:myRegion animated:YES];
//annotation
NSMutableArray * locations = [[NSMutableArray alloc] init];
CLLocationCoordinate2D location;
Annotation * myAnn;
//NUH location
myAnn = [[Annotation alloc] init];
location.latitude = NUH_longitude;
location.longitude = NUH_longitude;
myAnn.coordinate = location;
myAnn.title = @"NUH";
[locations addObject:myAnn];
//NHGP location
myAnn = [[Annotation alloc] init];
location.latitude = NHGP_latitude;
location.longitude = NHGP_longitude;
myAnn.coordinate = location;
myAnn.title = @"National Healthcare Group Polyclinic ";
[locations addObject:myAnn];
//NUHER location
myAnn = [[Annotation alloc] init];
location.latitude = NUHER_longitude;
location.longitude = NUHER_longitude;
myAnn.coordinate = location;
myAnn.title = @"National University Hospital Emergency Room";
[locations addObject:myAnn];
//NUCIS location
myAnn = [[Annotation alloc] init];
location.latitude = NUCIS_longitude;
location.longitude = NUCIS_longitude;
myAnn.coordinate = location;
myAnn.title = @"National University Cancer Institute Singapore";
[locations addObject:myAnn];
//Viva-UCCC location
myAnn = [[Annotation alloc] init];
location.latitude = VivaUCCC_latitude;
location.longitude = VivaUCCC_longitude;
myAnn.coordinate = location;
myAnn.title = @"Viva-University Children's Cancer Centre";
[locations addObject:myAnn];
[self.mapview addAnnotations:locations];
這個錯誤通常發生在座標無效時。確保緯度從-90到+90,經度從-180到+180。請參閱http://stackoverflow.com/questions/5872547/warning-in-custom-map-annotations-iphone?lq=1。 – Anna
我從谷歌地圖得到座標,緯度是從-90到+90,經度是從-180到+180的所有我的註釋引腳。但仍然無法讓我的所有引腳工作。 @AnnaKarenina – user2621090
顯示添加註釋的代碼(編輯您的問題並添加代碼)以及如何設置座標屬性。 – Anna