当UIScrollView将touch事件截获时,我们可以要写个UIScrollView的类别,把事件从UIScrollView传出去!
@implementation UIScrollView (UITouch)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//if(!self.dragging)
{
[[self nextResponder] touchesBegan:touches withEvent:event];
}
[super touchesBegan:touches withEvent:event];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
//if(!self.dragging)
{
[[self nextResponder] touchesMoved:touches withEvent:event];
}
[super touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
//if(!self.dragging)
{
[[self nextResponder] touchesEnded:touches withEvent:event];
}
[super touchesEnded:touches withEvent:event];
}
@end然后重写nextResponder的touch方法就可以了。
本文介绍了一种方法,通过创建UIScrollView的子类并重写touch事件处理方法,使得UIScrollView能够将touch事件传递给其下方的视图。这种方法适用于解决UIScrollView拦截触摸事件导致下方视图无法响应的问题。

2029

被折叠的 条评论
为什么被折叠?



