在UITableView上添加了UITapGestureRecognizer后会导致didSelectRowAtIndexPath失效,原因是UITapGestureRecognizer会截取了tableView的touch事件,导致无法响应行选择,解决方法是重写UIGestureRecognizerDelegate中的
1 -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch 2 { 3 if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//如果当前是tableView 4 //做自己想做的事 5 return NO; 6 } 7 return YES; 8 }