在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