Here we add long press gestures for TableView
Uilongpressgesturerecognizer *LONGPRESSGR = [[uilongpressgesturerecognizeralloc] initwithtarget:selfAction: @selector (longpressaction:)];
Longpressgr. minimumpressduration = 0.5f;
LONGPRESSGR. numberoftouchesrequired =1;
[_tableview addgesturerecognizer: LONGPRESSGR];
[LONGPRESSGR release];
At this point we will find that each time you hold down TableView and release, Longpressaction: This method executes 2 times
-(void) Longpressaction: (uilongpressgesturerecognizer *) longpress
{
if (longpress. State == Uigesturerecognizerstatebegan) {
cgpoint point = [longpress locationinview:_tableview];
nsindexpath *indexpath = [_tableviewindexpathforrowatpoint:p oint]; Can get us on which cell to long press
if (Indexpath! = Nil) {
NSLog (@ "%ld", Indexpath. row);
}
}
}
iOS adds a long-tap gesture to TableView's cell two times (Uilongpressgesturerecognizer)