当前位置: 首页 > 工具软件 > GMGridView > 使用案例 >

GMGridView上下拖动时禁掉左右移动

苏法
2023-12-01

项目中使用了GMGridView,可是这个view是在一个横向的scrollview中,结果上下滑动GMGridView的时候,左右也可以滑动


看了下GMGridView的源码,加入这两段代码即可解决这个问题,如果有重复的方法,就替换掉


- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if([touch.view isKindOfClass:[UIControl class]]) {
        return NO;
    }
    
    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    if ([gestureRecognizer isKindOfClass:[NSClassFromString(@"UIScrollViewPanGestureRecognizer")  class]]) {
        return NO;
    }
    return YES;
}


 类似资料: