-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{//给cell添加手势tap ,longtap都行
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapGestureRecognizer:)];
[cell addGestureRecognizer:tap];
}
下面是实现方法
-(void)TapGestureRecognizer:(UITapGestureRecognizer *)sender
{
// 240,20 , 25,25
//添加手势获取cell的信息
if ([(UITapGestureRecognizer *)sender state] == UIGestureRecognizerStateRecognized)
{
NSIndexPath * aIndexPath = [mTableView indexPathForCell:((UITableViewCell *)(sender.view))];
CGPoint point = [(UITapGestureRecognizer *)sender locationInView:mTableView];
int a = point.y - tmpheght;
NSLog(@"point=%f:%d",point.x,a % 150);
// int a = 4%2;
if (point.x >240.0 && point.x<=265.0 && a % 150>=20.0 &&a % 150<= 45)
{
aIndexPath = [mTableView indexPathForRowAtPoint:point];
ChatItem *item = [_dataArray objectAtIndex:aIndexPath.row];
NSLog(@"zhende jiade a ---------%@",item.UserName);
[fl becomeFirstResponder];
fl.text = [NSString stringWithFormat:@"%@说:",item.UserName] ;
}
}
}