如何在地图注释图钉上自动显示气泡而不放置动画



>我有一个标准注释图钉,放在我的坐标上,自动显示带有标题/副标题的气泡。在移动中跟踪我的坐标时,图钉每次都会掉落动画。我试图annView.animatesDrop=FALSE但在这种情况下,气泡不会自动出现(对于自动外观,我使用了selectAnnotation:addAnnotation animated:YES)。需要做什么才能使带有自动标题/字幕显示而没有拖放动画的引脚?

附言对不起,我的英语不好。

annView.animatesDrop=NO;

它适用于我的代码。显示不带拖放动画的图钉。

你必须使用 annView.animatesDrop=FALSE,但在正确的位置。那将在

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation 

委托方法,在创建该批注视图之后立即进行。

如果我记得不错的话,您不能在添加注释的同一运行循环中选择注释视图。我使用

- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay

为此,请将延迟设置为 0 以使其在新的运行循环中发生。

就我而言,我有

[self performSelector:@selector(selectPlace:) withObject:annotation afterDelay:0];

- (void)selectPlace:(id)<MKAnnotation>place{
//Lots of stuff for my precise case
    CLLocationCoordinate2D center;
    center.latitude = place.latitudeValue;
    center.longitude = place.longitudeValue;
    MKCoordinateSpan span;
    span.latitudeDelta = 4;
    span.longitudeDelta = 5;
    MKCoordinateRegion germany;
    germany.center = center;
    germany.span = span;
    [mapView setRegion:germany animated:YES];
// End of custom stuff
    [mapView selectAnnotation:(id)place animated:YES];  //This is what you're interested in
}

最新更新