嗨,我的数组充满了三个对象,地图上只显示了 1 个注释。有任何想法吗?如果我 NSLog 某些元素,它会被填充。只是无法显示 3 个注释。
NSMutableArray *currentBranch = [xmlParser branch];
int counter=[currentBranch count];
NSMutableArray *new = [[NSMutableArray alloc] init];
CLLocationCoordinate2D coordinates;
Mapdets * myAnn;
myAnn = [[Mapdets alloc] init];
[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];
MKCoordinateRegion region = {{0.0, 0.0}, {0.0,0.0 }};
region.center.latitude = -33.86434888;
region.center.longitude = 151.2090236;
region.span.longitudeDelta = 55.80f;
region.span.latitudeDelta = 55.80f;
[mapview setRegion:region animated:YES];
for(int i=0;i<counter;i++)
{
Mapdets *currentBranch = [[xmlParser branch] objectAtIndex:i];
NSString *title = currentBranch.title;
NSString *subtitle = currentBranch.subtitle;
NSString *lat = currentBranch.lat;
NSString *lng = currentBranch.lng;
coordinates.latitude = [lat doubleValue];
coordinates.longitude = [lng doubleValue];
myAnn.coordinate = coordinates;
myAnn.title = title;
myAnn.subtitle = subtitle;
NSLog(@"%@", title);
[new addObject:myAnn];
}
[mapview addAnnotations:new];
谢谢您的帮助!