我想添加多個引腳在相同的位置。如何添加多個引腳在相同的緯度/長
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];
}
上面的代碼代表加入mulitiple註釋 但很多針在相同的位置
所以我只能看到。 最後一次,也是當時的第二次。下面 對於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;
}
有什麼問題的代碼?你什麼都不問。 – rdurand
他還挺會......在「如何添加多個銷」 – mkral
同一緯度長,我想把50多針,但它顯示了兩個引腳只 –