簡體   English   中英

如何在地圖注解圖釘上自動顯示氣泡而無需放置動畫

[英]How to display bubble on map annotation pin automatically without drop animation

我有一個標准的注釋圖釘,放在我的坐標上,自動顯示帶有標題/字幕的氣泡。 在移動中跟蹤我的坐標時,銷子每次都會放下動畫。 我嘗試annView.animatesDrop=FALSE但是在這種情況下,氣泡不會自動出現(對於自動外觀,我使用了selectAnnotation:addAnnotation animated:YES )。 要使圖釘具有自動顯示的標題/字幕而沒有放置動畫,該怎么辦?

PS對不起,我的英語不好。

annView.animatesDrop = NO;

它在我的代碼中有效。 顯示沒有放置動畫的圖釘。

您必須在適當的位置使用anView.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
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM