I set uitableviewcellselectionstylenone on cells when I created cell. On long press I need to select exact cell, is it posible to do?
Asked
Active
Viewed 447 times
2
-
1You could add a gesture recogniser, or create a custom cell which doesn't draw the blue highlight on tap but still sends the "did select" delegate call. – mattjgalloway Dec 09 '11 at 11:38
1 Answers
1
Add a UILongPressGestureRecognizer
to the table. You can find out the cell on which the user long-pressed by calling indexPathForRowAtPoint
.
CGPoint p = [gestureRecognizer locationInView:self.myTableView];
NSIndexPath *indexPath = [self.myTableView indexPathForRowAtPoint:p];
See the accepted answer to this question for a complete example.

Community
- 1
- 1

Sergey Kalinichenko
- 714,442
- 84
- 1,110
- 1,523
-
You can also use `[self.tableView indexPathForCell:cell]` to get the index path – hypercrypt Dec 09 '11 at 14:11
-
@hypercrypt But I do not have a cell in the callback of the gesture recognizer: all it gives me is a point of the touch. – Sergey Kalinichenko Dec 09 '11 at 14:14