ios - 捕获并停止传播用户交互 iOS UITableViewCell

标签 ios uitableview opengl-es-2.0 user-interaction

我正在做一些自定义绘制我已经子类化的 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/

相关文章:

ios - Objective C ceil 返回错误值

ios - Objective-C 中的委托(delegate)级联和劫持委托(delegate)回调

ios - PFQueryTableViewController 在推送时有一条线穿过单元格

ios - objective-c 使用 AutoResizingMask 将 UILabe 对齐到 UitableViewCell 内部

ios - OpenGL - 将多个程序的输出传递到新纹理

ios - Clean Swift - 没有 segue 的路由

iphone - date From String 返回不正确的日期

ios - 显示复选标记附件 View 移动表格内容

iOS 模拟器 GL_OES_standard_derivatives

android - 将可绘制资源加载到纹理中并渲染它