IOS ScrollView 子控件滑动手势冲突


允许子视图手势延时响应

delaysContentTouches设 置为YES,

CanCancelContentTouches设置为NO

以上设置了只是达到停顿0.5秒后,子控件可以手势拖动


如果想直接响应,重写ScrollView 的 touches方法,判断传入的视图

而后使用- (BOOL)touchesShouldCancelInContentView:(UIView *)view来决定scrollview是否需要滚动。 

delaysContentTouches设 置为NO, 取消延迟响应

CanCancelContentTouches设置为 YES ,这样才能响应 touchesShouldCancelInContentView方法


@implementation ImageScrollView

-(instancetype)initWithFrame:(CGRect)frame
{
    
    if (self == [super initWithFrame:frame]) {
        ;
    }
    return self;
    
}

-(instancetype)init
{
    self = [super init];
    return self;
}

-(BOOL)touchesShouldCancelInContentView:(UIView *)view
{
    
    if ([view isKindOfClass:[UIImageView class]])
    {
        return NO;
    }
    
    return YES;
}


你可能感兴趣的:(IOS_UIKit库)