Long press on UITableView

- (UITableViewCell *) tableView:(UITableView *)tableView
          cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  UITableViewCell *cell = ...
  // remove blue selection
  cell.selectionStyle = UITableViewCellSelectionStyleNone;

  UILongPressGestureRecognizer *gesture = [[[UILongPressGestureRecognizer alloc]   
    initWithTarget:self action:@selector(handleTableViewCellLongPress:)] autorelease];
  [cell addGestureRecognizer:gesture];

  return cell;
}

- (void) handleTableViewCellLongPress:(UILongPressGestureRecognizer *)gesture
{
  if (gesture.state != UIGestureRecognizerStateBegan)
    return;

  UITableViewCell *cell = (UITableViewCell *)gesture.view;

    NSIndexPath *indexPath = [tvDocuments indexPathForCell:cell];


}

猜你喜欢

转载自zl4393753.iteye.com/blog/1748245
今日推荐