0
我一直在试图让地图上显示多个地图,但它不起作用。谁能帮我吗?我正在使用下面的代码:添加地图注释
- (void)viewDidLoad
{
// Set some coordinates for our position (Buckingham Palace!)
CLLocationCoordinate2D location;
location.latitude = (double) 51.501468;
location.longitude = (double) -0.141596;
// Add the annotation to our map view
MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Buckingham Palace" andCoordinate:location];
[self.mapView addAnnotation:newAnnotation];
}
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 1500, 1500);
[mv setRegion:region animated:YES];
[mv selectAnnotation:mp animated:YES];
}
在viewDidLoad中,检查mapView是否为零。 didAddAnnotationViews会被调用吗(把NSLog放进去检查)? – Anna 2012-02-05 15:40:46