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 回答