我正在使用3.1.3 SDK的iPhone應用程序,我的應用程序發現用戶當前的位置,顯示它在的MKMapView,然後查找附近的位置並將它們呈現爲MKAnnotations。我的代碼工作,但有時附近的註解不會顯示在地圖上。他們仍然被做成我看到了(它運行的註解是由剛剛從後NSLog的)控制檯正確的數據。MKAnnotations正在成功地進行了,但是他們有時無法呈現上的MKMapView
當它失敗完全是隨機的,也可能是第五次我打「生成和運行」爲天,或第500它不會出現有任何的圖案,並且不拋出任何類型的錯誤,它只是不會將註釋添加到MapView。
這就是所謂的每個位置附近添加MKAnnotation的方法。
- (void)addPinsWithLocation:(NSDictionary *)spot
{
CLLocationCoordinate2D location;
location.longitude = [[spot objectForKey:@"spot_longitude"] doubleValue];
location.latitude = [[spot objectForKey:@"spot_latitude"] doubleValue];
PlaceMarks *placemark = [[PlaceMarks alloc] initWithCoordinate:location title:[spot objectForKey:@"spot_name"] subtitle:@""];
NSLog(@"Adding Pin for Location: '%@' at %f, %f", [spot objectForKey:@"spot_name"], location.latitude, location.longitude);
[mapView addAnnotation:placemark];
}
如何讓MKAnnotations總是表現出任何的想法?