电池专业版充电屏保页面增加手势后 如何使一部分区域不响应

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event

{

    CGRect myRectUp = [selfconvertRect:CGRectMake(0,0, 28, 85)fromView:self];

    CGRect myRectDown = [selfconvertRect:CGRectMake(0,85+62, 28,GNDEVICE_SCREEN_HEIGHT-85-28)fromView:self];

    if (CGRectContainsPoint(myRectUp, point) ||CGRectContainsPoint(myRectDown, point) || (pullOffButton.hidden ==YES)) {

        self.userInteractionEnabled =NO;

    } else {

        self.userInteractionEnabled =YES;

    }

    UIView *result = [superhitTest:point withEvent:event];

    return result;

}






还有一个朋友提出一种解决办法 ,就是可以在不需要响应手势的区域加上别的控件,例如UIButton,然后用下面的方法来弄,但不知道什么原因,我这样弄并不管用:

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
  UIView* result = [super hitTest:point withEvent:event];
 
  if ([result isKindOfClass:[UIButton class]])
  {
    self.scrollEnabled = NO;
  }
  else
  {
    self.scrollEnabled = YES;
  }
  return result;
}

你可能感兴趣的:(电池专业版充电屏保页面增加手势后 如何使一部分区域不响应)