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

时间:2021-01-08 08:47:45

在有全屏侧滑的情况下,页面上有个slider需要左右滑动的时候,经常在滑动slider的时候页面也跟着滑动               
  -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
解决办法一:关闭当前页面的全屏侧滑,开启系统侧滑  
self.fd_interactivePopDisabled = YES;  //关闭全屏侧滑
self.navigationController.interactivePopGestureRecognizer.enabled = YES; //开启系统侧滑 
解决办法二:if (点击事件在slider上) {
                         关掉全屏侧滑;
                      } else {
                         开启全屏侧滑;
                      }
 
View上
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
  UIView *hitView = [super hitTest:point withEvent:event];
  if (hitView == _mySlider) {
    _sliderBlock11(YES);
    return hitView;
  } else {
    _sliderBlock11(NO);
    return nil;
  }
}
ViewController上
__weak ViewController *weakSelf = self;
sliderV.sliderBlock11 = ^ (BOOL aaa){
weakSelf.fd_interactivePopDisabled = aaa;
};

Demo:http://i.cnblogs.com/Files.aspx