Problem: Using Addgesturerecognizer:onetap causes the Didselectrowatindexpath method to fail
Add a UIView, and then add table to this view, to this view using Addgesturerecognizer gesture click function, resulting in table Didselectrowatindexpath method invalidation.
Part of the code for registering gestures in Viewdidload is as follows:
[CPP]View Plaincopy
- [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*) Indexpath not executed.
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
- #pragma mark-uigesturerecognizerdelegateBOOL
- , Nsstringfromclass ([Touch.view class
- Ifclass]) {
- Returnreturn}
Debug again, this time Didselectrowatindexpath responds, solve the problem of UITapGestureRecognizer gesture intercept touch event!
After adding uitapgesturerecognizer gesture recognition in iOS, UITableView's didselectrowatindexpath fails