原因是:UIView的touch事件被UIScrollView捕获了
1.应该加一个UIScrollView的category的扩展槽
![](https://img.haomeiwen.com/i5557751/6206aab9f0a167e4.png)
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 {
}
网友评论