默认显示当前位置注释

时间:2012-05-11 16:57:08

标签: ios annotations mapkit default show

我在mapkit中显示了当前位置注释(蓝点)。在录制蓝点后显示注释, 当我启动视图时,如何在默认情况下显示注释?发出针脚。

 - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views {
    for(MKAnnotationView *annotationView in views) {
        if(annotationView.annotation == mv.userLocation) {

            self.mapView.userLocation.title= @"Current";
            self.mapView.userLocation.subtitle= @"Location";

            MKCoordinateRegion region;
            MKCoordinateSpan span;

            span.latitudeDelta=0.002;
            span.longitudeDelta=0.002; 

            CLLocationCoordinate2D location=mv.userLocation.coordinate;

            region.span=span;
            region.center=location;

            [mv setRegion:region animated:YES];
            [mv regionThatFits:region];

        }
    }

}

1 个答案:

答案 0 :(得分:1)

在这种情况下,selectAnnotation应该可以工作,不是吗?只需在一小段时间后执行Selector。

....与以前相同的代码,但插入此内容:

            id annotation = annotationView.annotation;
            [self performSelector:@selector(selectUserLocation:) withObject:annotation afterDelay:0.1f];
        }
    }
}

- (void)selectUserLocation:(id)annotation{
    [self.mapView selectAnnotation:annotation animated:YES];
}