美文网首页iOS技术栈iOS接下来要研究的知识点
iOS手势冲突(JXCategoryView滚动手势与侧滑、UI

iOS手势冲突(JXCategoryView滚动手势与侧滑、UI

作者: 汗青fullstack | 来源:发表于2021-01-20 13:08 被阅读0次
    iOS手势冲突(JXCategoryView滚动手势与侧滑、UITableView又划删除)

    解决后的效果图 (待定上传)

    JXCategoryListContainerViewDelegate 提供了一个可选的协议方法:

    @optional
    /**
     返回自定义UIScrollView或UICollectionView的Class
     某些特殊情况需要自己处理UIScrollView内部逻辑。比如项目用了FDFullscreenPopGesture,需要处理手势相关代理。
    
     @param listContainerView JXCategoryListContainerView
     @return 自定义UIScrollView实例
     */
    - (Class)scrollViewClassInlistContainerView:(JXCategoryListContainerView *)listContainerView;
    

    看到这个我就知道怎么弄了,咱们可以自定义一个自定义UIScrollView或UICollectionView 在里面实现手势的控制,我这里初始化[[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]因此需要自定义一个UIScorllView来控制手势,让它兼容多种手势共存
    1.ServiceScrollView.h

    @interface ServiceScrollView : UIScrollView<UIGestureRecognizerDelegate>
    
    @end
    

    2.ServiceScrollView.m

    @implementation ServiceScrollView
    
    /**
     重载UIScrollView手势
     是否支持多手势触发,1.返回YES,则可以多个手势一起触发方法;2.返回NO则为互斥
     // called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
     // return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
     //
     // note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
     */
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
        if (gestureRecognizer.state != UIGestureRecognizerStatePossible) {
            return YES;
        } else {
            return NO;
        }
    }
    
    
    1. 在使用JXCategoryView的控制器中实现JXCategoryListContainerViewDelegate
    - (Class)scrollViewClassInlistContainerView:(JXCategoryListContainerView *)listContainerView
    {
        return [ServiceScrollView class];
    }
    

    相关文章

      网友评论

        本文标题:iOS手势冲突(JXCategoryView滚动手势与侧滑、UI

        本文链接:https://www.haomeiwen.com/subject/puhkzktx.html