ChavezChen / CWLateralSlide

One line of code to integrate 0 coupling side drawer!一行代码集成0耦合侧滑抽屉!
MIT License
1.28k stars 201 forks source link

框架右侧滑出手势和UIScrollView横向滑动手势冲突 #3

Closed WynterW closed 6 years ago

WynterW commented 6 years ago

框架侧滑出手势和UIScrollView横向滑动手势冲突,在设置ScrollView.userInteractionEnabled = NO时,侧滑手势可用。具体案例:类似QQ音乐在UIScrollView最左侧时,再滑动时唤出左侧菜单。

WynterW commented 6 years ago

解决了,将ScrollView单独分了出来,重写了- gestureRecognizerShouldBegin方法

#import "MyScrollView.h"

@implementation MyScrollView

/**
 *  重写手势,如果是左滑,则禁用掉scrollview自带的
 */
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
        UIPanGestureRecognizer *pan = (UIPanGestureRecognizer *)gestureRecognizer;
        if([pan translationInView:self].x > 0.0f && self.contentOffset.x == 0.0f) {
            return NO;
        }
    }
    return [super gestureRecognizerShouldBegin:gestureRecognizer];
}

@end
ChavezChen commented 6 years ago

👍👍👍👍

ChavezChen commented 6 years ago

我把你这种场景,更新到demo上了