这是myCell初始化方法
- (id)init {
[...]
_rightImg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 70, 70)];
[_rightImg setUserInteractionEnabled:YES];
UITapGestureRecognizer *tapGestureRecognizer = [
[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleRightImageTap)];
[_rightImg addGestureRecognizer:tapGestureRecognizer];
tapGestureRecognizer.delegate = self;
[self.contentView addSubview:_rightImg];
}
这是我在myCell中定义的处理程序方法
- (void) handleRightImageTap {
printf("TTTTAAAAPPPPP\n");
}
它不起作用,我也不知道我做错了什么。救命 !
最佳答案
编写这些行并进行测试,我认为imageView被其他视图覆盖
[self.contentView bringSubviewToFront:_rightImg];
[_rightImg setUserInteractionEnabled:YES];
[self.contentView setUserInteractionEnabled:YES];
希望这可以帮助