2012-06-06 22 views
1

我有一個MKAnnotationView,用戶可以在地圖上拖動。MKAnnotationView - 難以拖動

用戶很難拖動該引腳。我試圖增加幀的大小,並使用巨大的自定義圖像。但似乎沒有什麼實際上改變拖拽的命中區域大於默認值。

因此,在發生任何事情之前,我必須嘗試點擊/拖動大約十次。

MKAnnotationView *annView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"bluedot"] autorelease]; 

UIImage *image = [UIImage imageNamed:@"blue_dot.png"]; 

annView.image = image; 
annView.draggable = YES; 
annView.selected = YES; 
return annView; 

我在這裏錯過了什麼?

編輯:

原來的問題是,MKAnnotationView需要被感動,然後才能拖動。我遇到了麻煩,因爲附近有很多引腳,我的MKAnnotationView非常小。

回答

1

我沒有意識到需要觸摸MKAnnotationView才能拖動它。

爲了解決這個問題,我創建了一個定時器來定期選擇MKAnnotationView。

NSTimer *selectAnnotationTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(selectCenterAnnotation) userInfo:nil repeats:YES] retain]; 

和方法調用:

- (void)selectCenterAnnotation { 
    [mapView selectAnnotation:centerAnnotation animated:NO];  
}  
0

而不是使用一個定時器,你可以選擇鼠標的註解了。這樣您就不會混淆註釋選擇,並且沒有爲每個註釋始終運行的計時器。

我在開發一個mac應用程序時遇到了同樣的問題,並且在鼠標向下選擇註釋後,拖動效果很好。