针对UIScrollView可以响应触摸事件

原因是:UIView的touch事件被UIScrollView捕获了

1.应该加一个UIScrollView的category的扩展槽


针对UIScrollView可以响应触摸事件_第1张图片

2.扩展槽内写如下方法

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

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

[super touchesBegan:touches withEvent:event];

}

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

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

[super touchesMoved:touches withEvent:event];

}

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

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

[super touchesEnded:touches withEvent:event];

}

3.  在你要调用的页面 增加一个UIscrollview对象的属性

_scrollView.delaysContentTouches = NO;

4. 写你要执行的方法

//触摸开始

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

}

//触摸移动

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

}

//触摸结束

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

}

你可能感兴趣的:(针对UIScrollView可以响应触摸事件)