UITableViewCell里的UIImageView添加点击事件无响应,求助。

在 cellForRowAtIndexPath里定义cell

zhizhao为UIImageview,tapPhoto不管有无参数都没有任何响应。

代码如下:

 CAPictureViewCell *caCell=[[NSBundle mainBundle]loadNibNamed:@"CAPictureViewCell" owner:self options:nil][0];
        NSString *path = self.dic[@"imgpath"];
        [caCell.zhizhao setUserInteractionEnabled:YES];
        
        UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] init];
        [recognizer addTarget:self action:@selector(tapPhoto)];
        
        NSString* zhizhaoUrl = [path stringByAppendingString:self.dic[@"apliinfo"][@"business_licence_number_electronic"]];
        [caCell.zhizhao setImageWithURL:[NSURL URLWithString:zhizhaoUrl] placeholderImage:PLACEHOLDER];
        
        [caCell.zhizhao addGestureRecognizer:recognizer];
    
    
    viewDidLoad方法里:
    self.view.userInteractionEnabled = YES;
    self.infoTable.userInteractionEnabled = YES;
阅读 7.9k
2 个回答

cell.zhozhao的允许交互方式要设置为yes。不过,你用拼音命名也是醉了。

图片描述

打断点看你设置userInteractionEnabled属性点时候视图初始化了没

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏