part of the code for registering gestures in Viewdidload is as follows: [CPP] View plaincopy UITapGestureRecognizer*onetap =[[[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (Hidekeyboard)] autorelease]; Onetap.Delegate=Self ; Onetap.numberoftouchesrequired=1; [Self.view Addgesturerecognizer:onetap]; One of the Hidekeyboard methods is omitted, the basic is a few resignfirstresponder. Then there was a strange phenomenon, click on the "Retrieve password" column when no response!!! After debugging I found that the delegate method- (void) TableView: (UITableView *) TableView Didselectrowatindexpath: (nsindexpath*) The Indexpath does not execute. The visual reason is that UITapGestureRecognizer intercepted the touch event, causing the Didselectrowatindexpath method to fail to respond. A workable workaround was found after reviewing the relevant documents: overriding the Uigesturerecognizerdelegate in the-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) Touch method. [CPP] View plaincopy#pragmaMark-uigesturerecognizerdelegate-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) Touch {//The class name of the view that outputs the clickNSLog (@"%@", Nsstringfromclass ([Touch.viewclass])); //if Uitableviewcellcontentview (that is, click Tableviewcell), the touch event is not intercepted if([Nsstringfromclass ([Touch.viewclass]) Isequaltostring:@"Uitableviewcellcontentview"]) { returnNO; } returnYES; } debug again, this time didselectrowatindexpath response, solve the uitapgesturerecognizer gesture intercept Touch event problem!
After adding uitapgesturerecognizer gesture recognition in iOS, UITableView's didselectrowatindexpath fails