Ipad UITAPPgestureRecognitor

Ipad UITAPPgestureRecognitor,ipad,uitapgesturerecognizer,Ipad,Uitapgesturerecognizer,如何使用 -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { } 方法?手势识别器具有locationInView:view方法。 UIgestureRecognitor还有.view属性,所以您可以使用它。下面是一个示例 -(void)handleGesture:(UIGestureRecognizer *)gestureRecogniz

如何使用

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

方法?

手势识别器具有locationInView:view方法。 UIgestureRecognitor还有.view属性,所以您可以使用它。

下面是一个示例

-(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];
}