在自定义使用UILong pressGestureRecognizer麻烦MKAnnotationView [英] Trouble using UILongPressGestureRecognizer in custom MKAnnotationView

查看:313
本文介绍了在自定义使用UILong pressGestureRecognizer麻烦MKAnnotationView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于采用了具有UILong pressGestureRecognizer麻烦MKAnnotationView的自定义子类。回调只是间歇性地解雇了。如果我让最低pressDuration短,它触发更频繁。随着0.1的最低pressDuration价值,它触发每次。随着0.4的值,它永远不会触发可言,不管多久,我离开我的手指上。在0.2被击中或错过。

Having trouble with a UILongPressGestureRecognizer in a custom subclass of MKAnnotationView. The callback is fired only intermittently. If I make the minimumPressDuration shorter, it fires more frequently. With a minimumPressDuration value of 0.1, it fires every time. With a value of 0.4, it never fires at all, no matter how long I leave my finger on it. At 0.2 it is hit or miss.

如果我用一个点击手势(如下),它工作正常。我使用的是其它视图的龙preSS的手势,他们做工精细。这只是对我有这个问题MKAnnotationView,所以我不知道是否对一些在AnnotationViews其他内部事件回调都干扰(编号等)。

If I use a Tap gesture (as below), it works fine. I'm using LongPress gestures on other views and they work fine. It's just on the MKAnnotationView that I have this problem, so I'm wondering if some of the other internal event callbacks on AnnotationViews are interfering (callout, etc).

我看到的iOS4(SIM卡和手机)和3.2(SIM卡,没有一个设备)。

I see this problem on iOS4 (sim and phone) and 3.2 (sim, don't have a device).

下面是如何我创建了手势识别:

Here is how I'm creating the gesture recognizer:

#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

和回调方法在这个类定义如下:

And the callback methods are defined in this class as follows:

- (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer {
    NSLog(@"LONG PRESS");
}

- (void)handleTap:(UIGestureRecognizer *)gestureRecognizer {
    NSLog(@"TAP");
}

任何iPhone大师有任何想法,为什么这可能发生?

Any iPhone gurus have any idea why this might be happening?

推荐答案

据我所知在3.2和iOS 4的标记已经连接了很长的preSS的姿态来处理标记拖动。难道说一个与您长期preSS手势识别的干扰?也许这就是为什么持续时间较短的作品;它捕获手势内置的长preSS识别器前。

As far as I know the markers in 3.2 and iOS 4 already have a long press gesture attached to them to handle marker dragging. Could it be that that's interfering with your long press gesture recognizer? Maybe that's why a shorter duration works; it catches the gesture before the built in long press recognizer can.


  • 这只是一个猜测*

这篇关于在自定义使用UILong pressGestureRecognizer麻烦MKAnnotationView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆