我在我的 uitableviewcell
上添加了 UITapGestureRecognizer
就像
Mycell *outCell = (Mycell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!outCell) {
outCell = [[Mycell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[outCell.bubbleView addGestureRecognizer:recognizer];
}
outCell.bubbleView 添加到 contentview,outCell.bubbleView 根据图像大小调整大小传递给 Mycell。
当我的应用程序运行时,TapGestureRecognizer
仅在我点击单元格顶部时触发(其中高度等于默认单元格高度,单元格的其他部分不是)
对我的问题有任何答案吗?提前致谢。
最佳答案
试试下面的代码
Mycell *outCell = (Mycell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!outCell)
{
outCell = [[Mycell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
UIView *tapView = [[UIView alloc] initWithFrame:outCell.bounds];
tapView.backgroundColor = [UIColor clearColor];
tapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[tapView addGestureRecognizer:recognizer];
[outCell addSubview:tapView];
}
关于ios - TapGestureRecognizer 仅在 View 调整大小后位于 View 的一部分?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23629702/