我正在尝试在同一位置添加多个引脚。
for (int i = 0; i < [arrListing count]; i++) {
List *obj = [arrListing objectAtIndex:i];
NSLog(@"Title %@",obj.Title);
CLLocationCoordinate2D annotationCoord;
annotationCoord.latitude = [obj.lat floatValue];
annotationCoord.longitude = [obj.log floatValue];
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = annotationCoord;
annotationPoint.title = obj.Title;
[mapView addAnnotation:annotationPoint];
}
上面的代码表示添加多个注释,但许多引脚位于同一位置
所以我只能看到。最后一个和倒数第二个。 下面是 viewForAnnotation 的代码
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
MKPinAnnotationView *annView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"annView"];
if (!annView) {
annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annView"];
annView.pinColor = MKPinAnnotationColorRed;
annView.animatesDrop = YES;
annView.canShowCallout = YES;
NSLog(@"iRow :%d",iRow);
annView.tag = iRow++;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.rightCalloutAccessoryView = rightButton;
NSLog(@"if condition");
}
else
{
annView.annotation = annotation;
NSLog(@"else condition");
}
return annView;
}