1

地図上にドロップするピンがあり、現在の場所が青い点で表示されます。追加した:

- (MKAnnotationView *)mapView:(MKMapView *)amapView viewForAnnotation:(id<MKAnnotation>)annotation{


    NSString *identifier =@"mypin";
    MKPinAnnotationView *pin = (MKPinAnnotationView *) [amapView dequeueReusableAnnotationViewWithIdentifier:identifier];
    if(pin ==nil){
        pin = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
    }else{
        pin.annotation = annotation;
    }

    UIButton *myDetailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    myDetailButton.frame = CGRectMake(0, 0, 23, 23);
    myDetailButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    myDetailButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

    [myDetailButton addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];

    pin.rightCalloutAccessoryView = myDetailButton;
    pin.enabled = YES;
    pin.animatesDrop = TRUE;
    pin.canShowCallout = YES;

    return pin;
}

しかし、現在の場所は青い点ではなくピンです。現在の場所の注釈がピンになるのを止めて、青い点のままにしておくにはどうすればよいですか。

何か助けてください。

4

3 に答える 3

0

単純 :

- (MKAnnotationView *)mapView :(MKMapView *)maapView viewForAnnotation:(id <MKAnnotation>) annotation{
    @autoreleasepool {


    if (annotation == maapView.userLocation)
    {
        // This code will execute when the current location is called.
        return nil;
    }
    else
    {
        MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
        annView.pinColor = MKPinAnnotationColorPurple;
        annView.animatesDrop=YES;
        annView.canShowCallout = YES;
        annView.calloutOffset = CGPointMake(-5, 5);
        UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        [rightButton setTitle:annotation.title forState:UIControlStateNormal];

        annView.rightCalloutAccessoryView = rightButton;
        return annView;
    }

}
}
于 2013-06-28T05:50:33.350 に答える