ios - UITableViewCell 中的自定义 UIView 阻止 uitableviewcell 接收事件

标签 ios uitableview uiview touch-event touchesbegan

我有一个自定义的 UITableViewCell 即我继承了 UITableViewCell 类 在填充 uitableview 的每个单元格(或行)时,我正在创建我的自定义 UITableViewCell,它由图像和一些标签组成。

现在,当我在我的自定义“UITableViewCell”类中覆盖以下方法时,

 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    NSLog(@"CLICKED CLICKED CELL CLICKED CLICKED");
    [super touchesBegan:touches withEvent:event];
 }

如果我单击添加到我的自定义 uitableviecell 中的自定义 View ,它永远不会被调用,但是当我单击其上没有自定义 View 的区域时它很好(事件触发)。

我的目标很简单,我想检测 uitableview 中每一行 (uitableviewcell) 中的任何触摸。

最佳答案

我今天遇到了类似的问题,我无法选择单元格,因为它有一个带有 ScrollView 的自定义 UIView。尝试在 UIView 的 subview 上设置 userInteractionIsEnabled = false

关于ios - UITableViewCell 中的自定义 UIView 阻止 uitableviewcell 接收事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10725938/

相关文章:

objective-c - ARC 适用于所有对象?

ios - 自定义导航栏返回栏按钮

ios - 在 TableView 行中动态对齐 UITextView

ios - 将 subview 置于所有其他 View 的前面

iphone - iOS5 显示MIME消息

ios - 通过 API 使用 Alamofire 将 STL 文件上传到 Octoprint

ios - 如何以编程方式复制 UIView 并保存accessibilityId?

ios - iOS11出现键盘时,UITableView将键盘高度添加到contentSize

ios - TableView deleteRowsAtIndexPaths :withRowAnimation Very Slow

ios - xib 的 UIView 模糊