【问题标题】:UILongPressGestureRecognizer on MKAnnotationView not working for single touchMKAnnotationView 上的 UILongPressGestureRecognizer 不适用于单点触控
【发布时间】:2011-11-05 15:06:32
【问题描述】:

我一直在尝试在 MKAnnotationView 子类中使用 UILongPressGestureRecognizer。有趣的是,手势识别器仅在使用两个手指/触摸时触发。

是什么阻止了手势识别器仅通过一键触发?

实施

UILongPressGestureRecognizer *pressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
                                                                                                      action:@selector(handleLongPress:)];
pressRecognizer.minimumPressDuration = 0.25;
pressRecognizer.numberOfTapsRequired = 0;
pressRecognizer.numberOfTouchesRequired = 1;

普通UIView 中的相同实现显示了预期的一键操作行为。然而,可以使用touchesBegan:touchesEnded: 来获得长按手势工作我仍然很好奇这是什么原因。

【问题讨论】:

    标签: ios cocoa-touch mkmapview uigesturerecognizer mkannotationview


    【解决方案1】:

    你看过这个question 吗?

    为了使用我的 UILongPressGestureRecognizer,我禁用了 AnnotationView 并向其中添加了 GestureRecognizer:

    [ann_view setEnabled:NO];
    UILongPressGestureRecognizer* long_press = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAnnotationView:)];
    long_press.minimumPressDuration = 1.5;
    [ann_view addGestureRecognizer:long_press];
    [long_press release];
    

    【讨论】:

      猜你喜欢
      • 2012-08-06
      • 1970-01-01
      • 2015-12-03
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-14
      • 1970-01-01
      相关资源
      最近更新 更多