我正在做一些自定义绘制我已经子类化的 UITableViewCell。那里有一个需要用户交互才能工作的 OpenGL ES 2.0 控件……现在,如果我开始水平拖动,控件会响应,但一旦我沿垂直方向移动,它就会开始移动 TableView 的视口(viewport)。如何阻止此交互转到 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];
}
关于ios - 捕获并停止传播用户交互 iOS UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6954733/