针对UIScrollView可以响应触摸事件

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

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


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 {

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容