5

私は自分のアプリケーションでこの例を使用しましたが、

http://spitzkoff.com/craig/?p=81

しかし、accessorycontrolをタップしたので、calloutAccessoryControlTappedを呼び出したりトリガーしたりしません。

これが私のコードです。

- (void)viewDidLoad {
    MapAnnotation *annotation = nil;
    annotation = [[MapAnnotation alloc] initWithCoordinate:[[trackPointsArray objectAtIndex:trackPointsArray.count - 2] coordinate]];
    [mapView addAnnotation:annotation];
    [super viewDidLoad];
}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKAnnotationView *annotationView = nil;

    // start pin
    static NSString *StartPinIdentifier = @"StartPinIdentifier";
    MKPinAnnotationView *startPin = [annotationView dequeueReusableCellWithIdentifier:StartPinIdentifier];

    if (startPin == nil) {
        startPin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:StartPinIdentifier] autorelease];
        startPin.animatesDrop = YES;
        startPin.pinColor = MKPinAnnotationColorGreen;
        startPin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        startPin.canShowCallout = YES;
        startPin.enabled = YES;

        UIImage *image = [UIImage imageNamed:@"location.png"];
        UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
        startPin.leftCalloutAccessoryView = imgView;
    }

    annotationView = startPin;
    return annotationView;
}

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
     NSLog(@"calloutAccessoryControlTapped");
}

私はしばらくこの問題に苦しんでいますが、多くの人が同じ問題を抱えているようです。どんな助けでもいただければ幸いです。ありがとう

4

1 に答える 1

0

問題が解決しました!私の他のビューはマップビューをブロックしていました。[self setUserInteractionEnabled:NO];

于 2009-07-29T00:57:25.467 に答える