2014-05-13 43 views
0

我在我的uitableviewcell加入UITapGestureRecognizerTapGestureRecognizer仅在视图大小调整后的视图之外?

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被添加到内容查看,outCell.bubbleView根据图像大小被传递给了myCell调整大小。 当我的应用程序运行时,TapGestureRecognizer只在我点击单元格顶部时触发(其中高度等于默认单元格高度,其他单元格不是) 对我的问题有任何答案?先进的感谢。

+0

尽量给任何背景颜色泡看法,并尝试在其上敲击,然后看到的,是你的分接选择火与否。 –

+0

call recognizer.tag = indexpath.row; –

+0

分流选择器只在顶部区域发射,其高度等于默认高度(我猜),其他区域不是 – LViet

回答

1

试试下面的代码

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]; 
    } 
+0

问题还没有解决 – LViet

+0

不在任何地方或只有顶部只有水龙头? – Adithya

+0

是的,只在最上面,谢谢 – LViet