[英]Capture and stop propagation of user interaction iOS UITableViewCell
我正在做一些自定义绘制我已经子类化的UITableViewCell。 在那里有一个OpenGL ES 2.0控件需要用户交互才能工作......现在如果我开始水平拖动控件会响应,但是一旦我沿垂直方向移动,它就会开始移动表视图的视口。 如何阻止此交互转到UITableView并将其限制在UITableViewCell中我自己的UIView?
您可以尝试继承UITableView并覆盖以下方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
// if user tapped on your custom view, disable scroll
self.scrollEnabled = NO;
// end if
[super touchesBegan:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
self.scrollEnabled = YES;
[super touchesEnded:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
self.scrollEnabled = YES;
[super touchesCancelled:touches withEvent:event];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.