아래 코드는 내가 지금까지 사용해 왔던 것이며, 배열의 모든 객체를 올바르게 반복하지만, 모든 맵을 하나의 맵에 표시하려고 할 때 어레이에있는 마지막 obeject 만 맵에 추가합니다. 20 개가 전부가 아니기 때문에 표시하고 싶습니다.배열을 기반으로 한 mapview에 여러 주석을 갖는 방법
self.clientTable = [ClientDatabase database].clientTable;
ClientTable *info = nil;
[_nameLabel setText:info.name];
[_stateLabel setText:info.state];
//change the string to doubles for the map GPS co-ordinates
double latDouble = [info.latMap doubleValue];
double longDouble = [info.longMap doubleValue];
NSLog(@"%d",[self.clientTable count]);
int countArray = [self.clientTable count];
for (int i=0;i<countArray;i++) {
info = [self.clientTable objectAtIndex:i];
info.uniqueId=i;
NSLog(@" i = %d ; id = %d %@",i, info.uniqueId, info.name);
//set up the map
[super viewDidLoad];
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
MKCoordinateRegion region = {{0.0,0.0},{0.0,0.0}};
region.center.latitude = latDouble;
region.center.longitude = longDouble;
region.span.longitudeDelta =0.02; //degrees of acuracy, most precise best for this time
region.span.latitudeDelta =0.02; //degrees of accuracy
[mapView setRegion:region animated:YES];
// set up the annotation point
AllMap *annotationPoint = [[AllMap alloc] init];
annotationPoint.title = info.name;
annotationPoint.subtitle = info.state;
annotationPoint.coordinate = region.center;
[mapView addAnnotation:annotationPoint];
annotationPoint.isAccessibilityElement=YES;
//show annotation by default
[mapView selectAnnotation:annotationPoint animated:YES];
[mapView setDelegate:self];
}
죄송합니다. 코드가 쓰레기라면, 저는 iPhone 프로그래밍을 처음 사용합니다. 사전에
감사합니다 : D는
나는 각각의 ID에 대한 주석을 작성한 다음 각 루프 반복마다 새 주석을 작성할 것이라고 생각했지만 마지막 것에 도달 할 때까지 재정의했다. 링크를 잊어 버렸습니다. 감사합니다. –