【问题标题】:Why doesn't Xcode recognize -ignoreTouch:forEvent: in UITapGestureRecognizer subclass?为什么 Xcode 不能识别 -ignoreTouch:forEvent: 在 UITapGestureRecognizer 子类中?
【发布时间】:2013-07-27 19:59:30
【问题描述】:

根据documentation有一个方法-ignoreTouch:forEvent:。我需要模仿-pointInside:withEvent: 功能,使其仅处理特定形状的水龙头。

但是当我尝试调用这个方法时,Xcode 并不知道。没有自动完成功能,它会为未声明的方法提供错误。但是文档清楚地表明我们可以在 UITapGestureRecognizer 上调用 ignoreTouch:forEvent: 来忽略触摸。

编辑:文档说它有一个类扩展,但我也不能导入它。未找到:#import "UIGestureRecognizerSubclass.h"

【问题讨论】:

    标签: iphone ios ipad uikit uitapgesturerecognizer


    【解决方案1】:

    它是UIKit 的一部分,所以像这样导入它:

    #import <UIKit/UIGestureRecognizerSubclass.h>
    

    【讨论】:

      【解决方案2】:

      似乎当我这样做时它有效:

      #import <UIKit/UIGestureRecognizerSubclass.h>
      @implementation OFShapeTapGestureRecognizer
      - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
          //[self ignoreTouch:[touches anyObject] forEvent:event];
          // ... here, fancy logic.
          if (ignore) {
              self.state = UIGestureRecognizerStateCancelled;
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2014-01-02
        • 2014-10-28
        • 1970-01-01
        • 2010-10-19
        • 1970-01-01
        • 1970-01-01
        • 2019-10-04
        • 1970-01-01
        • 2018-03-01
        相关资源
        最近更新 更多