6

奇妙な動作の mapView があります。開くと、すべて正常に動作します。ユーザー (青色の円) の位置が特定され、3 つのピンが配置されます。しかし(理由はわかりません)しばらくすると、青い点がピンに変わります-ただし、接続速度が遅い場合のみです.

これが私が得たものです:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"pinView"];

    if (!pinView && ![annotation isKindOfClass:[MKUserLocation class]])
    {
        pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pinView"];
        pinView.pinColor = MKPinAnnotationColorRed;
        pinView.animatesDrop = YES;
        pinView.canShowCallout = YES;

        UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinView.rightCalloutAccessoryView = rightButton;

        if (annotation == self.locationZH1)
        {
            [pinView setTag:1];
        }
        else if (annotation == self.locationZH2)
        {
            [pinView setTag:2];
        }
        else if (annotation == self.locationZH3)
        {
            [pinView setTag:3];
        }
        else if (annotation == self.locationLU1)
        {
            [pinView setTag:4];
        }
    }
    else
    {
        pinView.annotation = annotation;
    }

    return pinView;
}
4

3 に答える 3

0

ユーザーの位置を示す青い点とその周囲の円を表示するには、annotation == mapView.userLocation のときに nil を返す必要があります。

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

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

    if (!pinView && ![annotation isKindOfClass:[MKUserLocation class]])
    {
        pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pinView"];
        pinView.pinColor = MKPinAnnotationColorRed;
        pinView.animatesDrop = YES;
        pinView.canShowCallout = YES;

        UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinView.rightCalloutAccessoryView = rightButton;

        if (annotation == self.locationZH1)
        {
            [pinView setTag:1];
        }
        else if (annotation == self.locationZH2)
        {
            [pinView setTag:2];
        }
        else if (annotation == self.locationZH3)
        {
            [pinView setTag:3];
        }
        else if (annotation == self.locationLU1)
        {
            [pinView setTag:4];
        }
        return pinView;
    }
    else
    {
        pinView.annotation = annotation;
        return Nil;
    }
}
于 2014-03-05T06:56:10.020 に答える