2012-05-11 143 views
2

我有一个当前位置注释(蓝点)显示在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]; 

     } 
    } 

} 
+0

没有你的代码的工作?缺少一些东西,比如mapView addAnnotation来调用它...呵呵,没想到showUserLocation的确和AddAnnotation一起工作。 –

回答

1

在这种情况下,selectAnnotation应该工作,不是吗?只需一段时间后执行选择器。

....相同的代码之前,但插入此:

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

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

谢谢!那是我需要的! –