【问题标题】:UITapGestureRecognizerUITapGestureRecognizer
【发布时间】:2010-10-14 10:26:48
【问题描述】:

如何使用

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
}

方法?

【问题讨论】:

    标签: ipad uitapgesturerecognizer


    【解决方案1】:

    手势识别器有 locationInView:view 方法。 UIGestureRecognizer 也有 .view 属性,所以你可以使用它。

    【讨论】:

      【解决方案2】:

      这是一个例子。

      -(void)handleGesture:(UIGestureRecognizer *)gestureRecognizer
      {
      CGPoint p = [gestureRecognizer locationInView:self.navigationController.toolbar];
      CGRect nextButtonRect = CGRectMake(self.navigationController.toolbar.frame.size.width * 2 / 3,
                                         0,
                                         self.navigationController.toolbar.frame.size.width / 3,
                                         self.navigationController.toolbar.frame.size.height);
      
      CGRect previousButtonRect = CGRectMake(0,
                                         0,
                                         self.navigationController.toolbar.frame.size.width / 3,
                                         self.navigationController.toolbar.frame.size.height);
      
      if (CGRectContainsPoint(previousButtonRect, p))
          [self tapOnPreviousNews];
      
      if (CGRectContainsPoint(nextButtonRect, p))
          [self tapOnNextNews];
      }
      

      【讨论】:

        猜你喜欢
        • 2023-04-07
        • 2012-09-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多