gpt4 book ai didi

ios - UITablevlewCell 内的 UIImageView 上的 UITapGestureRecognizer 未被调用

转载 作者:IT王子 更新时间:2023-10-29 07:49:22 26 4
gpt4 key购买 nike

我目前有一个自定义的 UITableViewCell,其中包含一个 UIImageView,并试图在 UIImageView 上添加一个 UITapGestureRecognizer,但没有成功。这是代码片段。

//within cellForRowAtIndexPath (where customer table cell with imageview is created and reused)
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleImageTap:)];
tap.cancelsTouchesInView = YES;
tap.numberOfTapsRequired = 1;
tap.delegate = self;
[imageView addGestureRecognizer:tap];
[tap release];

// handle method
- (void) handleImageTap:(UIGestureRecognizer *)gestureRecognizer {
RKLogDebug(@"imaged tab");
}

我还在单元格和 UIImageView 的 super View 上设置了 userInteractionEnabled,但仍然没有成功,有什么提示吗?

编辑:

我还通过 cell.selectionStyle = UITableViewCellSelectionStyleNone; 删除了单元格的选择;这会是个问题吗

最佳答案

UIImageView 的用户交互默认情况下是禁用的。您必须明确启用它以使其响应触摸。

imageView.userInteractionEnabled = YES;

关于ios - UITablevlewCell 内的 UIImageView 上的 UITapGestureRecognizer 未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7735247/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com