在MKAnnotationView的自定義子類中遇到UILongPressGestureRecognizer問題。回調只是間歇性地觸發。如果我使minimumPressDuration更短,它會更頻繁地觸發。在minimumPressDuration值爲0.1時,它每次都會觸發。值爲0.4時,無論我多久留下手指,它都不會起火。在0.2時,它被擊中或錯過。在自定義MKAnnotationView中使用UILongPressGestureRecognizer時遇到問題
如果我使用輕擊手勢(如下),它工作正常。我在其他視圖上使用LongPress手勢,並且它們工作正常。它只是在MKAnnotationView,我有這個問題,所以我想知道如果AnnotationViews上的其他內部事件回調是干擾(標註等)。
我在iOS4(SIM卡和手機)和3.2(SIM卡,沒有設備)上看到這個問題。
這裏是我要創建的這個手勢識別:
#define USE_LONG_PRESS 1
#define USE_TAP 0
#if USE_LONG_PRESS
UILongPressGestureRecognizer *longPressGR =
[[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
longPressGR.minimumPressDuration = 0.2;
[self addGestureRecognizer:longPressGR];
[longPressGR release];
#endif
#if USE_TAP
UITapGestureRecognizer *tapGR =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(handleTap:)];
[self addGestureRecognizer:tapGR];
[tapGR release];
#endif
而在這個類中定義回調方法如下:
- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"LONG PRESS");
}
- (void)handleTap:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"TAP");
}
任何iPhone大師有什麼想法,爲什麼這可能正在發生?
感謝 - 這是一個好點,但我認爲內置的draggability iOS4的只是添加?至少,可拖動的屬性只是添加了。有沒有其他的方式來拖動它們在3.2? – Chris 2010-09-15 23:27:24