UIScrollView不能响应touch事件的解决办法

UIScrollView本身事是不支持touch的,我们可以给她添加拓展

#import "UIScrollView+util.h"

 

@implementation UIScrollView (util)

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [[self nextResponder] touchesBegan:touches withEvent:event];

    [super touchesBegan:touches withEvent:event];

}

-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [[self nextResponder] touchesMoved:touches withEvent:event];

    [super touchesMoved:touches withEvent:event];

}

-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    [[self nextResponder] touchesEnded:touches withEvent:event];

    [super touchesEnded:touches withEvent:event];

}

@end

posted @ 2016-01-07 09:13  V清风  阅读(494)  评论(0编辑  收藏  举报