0

なぜ機能しないのか想像できません。ピンの色を変更したり、この方法が提供する他の機能を使用したりしたいのですが、機能しません。たぶん私はこの方法を間違って使用していますか?例が一番いいでしょう、ありがとう。

    [mapView setMapType: MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
for (NSDictionary *dict in self.klubiArray3) {
double latid = [[dict valueForKey:@"LatiS"] doubleValue];
double longid =[[dict valueForKey:@"LongiS"] doubleValue];
MKCoordinateRegion region = {{0.0, 0.0}, {0.0, 0.0}};


region.span.latitudeDelta = 0.005;
region.span.longitudeDelta = 0.005;
region.center.latitude = latid;
region.center.longitude = longid;

[mapView setRegion:region animated:YES];

NewClass *ann = [[NewClass alloc] init];
ann.title = [dict valueForKey:@"AnnotM"];
ann.subtitle = [dict valueForKey:@"Adress"];;
ann.coordinate = region.center;

[mapView addAnnotation:ann ];
}
 }
#pragma mark MKMapViewDelegate
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
       NSLog(@"Controll comes here");

if (annotation == mapView.userLocation) 
    return nil;

MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"asdf"];

if (pin == nil)
    pin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier: @"asdf"] ;
else
    pin.annotation = annotation;
pin.userInteractionEnabled = YES;
UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
[disclosureButton setFrame:CGRectMake(0, 0, 30, 30)];

pin.rightCalloutAccessoryView = disclosureButton;
pin.pinColor = MKPinAnnotationColorPurple;
//pin.animatesDrop = YES;
[pin setEnabled:YES];
[pin setCanShowCallout:YES];
return pin;

 }
4

1 に答える 1

1

わかったのですが、InterfaceBuilderでマップデリゲートを接続するのを忘れていました。

于 2012-04-22T19:36:35.797 に答える