0

MKMapView注釈にズームインさせようとしています。私はあらゆる種類を試しましたが、ズームアウトしたままregionです。

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    NSLog(@"Did add annotations");
    MKAnnotationView *annotationView = [views objectAtIndex:0];
    id <MKAnnotation> mp = [annotationView annotation];
    MKCoordinateSpan span;
    span.longitudeDelta = 0.02;
    span.latitudeDelta = 0.02;
    MKCoordinateRegion region;

    region.center = mapView.userLocation.coordinate;
    region.span = span;

    [mapView selectAnnotation:mp animated:YES];
    [self.spotMapView setRegion:region animated:YES];
    [self.spotMapView regionThatFits:region];
}

これは実行されますが、マップはズームアウトされたままになります。

4

1 に答える 1

0

これに変更didAddAnnotationViews

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    NSLog(@"Did add annotations");
    MKAnnotationView *annotationView = [views objectAtIndex:0];
    id <MKAnnotation> mp = [annotationView annotation];
    [mapView selectAnnotation:mp animated:NO];
}

うまくいったようで、マップが拡大されます。

于 2012-10-29T10:15:04.293 に答える