- UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
- lpgr.minimumPressDuration = 1.0;
- lpgr.delegate = self;
- [mTableView addGestureRecognizer:lpgr];
- [lpgr release];
-
- -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
- {
- CGPoint p = [gestureRecognizer locationInView:mTableView ];
-
-
-
- NSIndexPath *indexPath = [mTableview indexPathForRowAtPoint:p];
- if (indexPath == nil)
- NSLog(@"long press on table view but not on a row");
- else
- NSLog(@"long press on table view at row %d", indexPath.row);
-
- }
UITableViewCell 添加长按手势
原文:http://www.cnblogs.com/CodingMann/p/4949178.html