给tableview添加tap点击事件:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(colseKeyBoardClick:)];
tap.delegate = self;
[self.tableView addGestureRecognizer:tap];
这样会导致点击cell的时候没有响应响应的方法,使用UIGestureRecognizerDelegate的方法解决这个冲突:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
//判断点击的是tableview响应手势的方法,否则不响应
if ([touch.view isKindOfClass:[UITableView class]]){
return YES;
}
return NO;
}
网友评论