tableview加tap手势,cell点击无效了

需求:点击空白收起筛选table

我在view加了tap手势, 点击空白,确实可以收起下拉筛选了,但是点击大table的cell不能跳转了!!!

`__weak typeof(self)weakSelf = self;

UITapGestureRecognizer *tableTap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
    [weakSelf foldHeaders];
}];
[self.view addGestureRecognizer:tableTap];`

设置cancelsTouchesInView这个属性就行了:

` __weak typeof(self)weakSelf = self;

UITapGestureRecognizer *tableTap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
    [weakSelf foldHeaders];
}];
tableTap.cancelsTouchesInView = NO;
[self.view addGestureRecognizer:tableTap];`

posted on 2022-03-02 13:54  土匪7  阅读(143)  评论(0编辑  收藏  举报