UITapGestureRecognizer与didSelectRowAtIndexPath冲突解决

需求要做一个这样的下拉弹窗 点击弹窗选中Cell 点击其他区域弹窗消失

UITapGestureRecognizer与didSelectRowAtIndexPath冲突解决_第1张图片
111.png

贴代码

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onTapDissMissSelf)];
      
      
      self.userInteractionEnabled = YES;
      
      tap.delegate = self;
      
      
      [self addGestureRecognizer:tap];

解决冲突代码 这个是UIGestureRecognizerDelegate 代理方法

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {//如果当前是tableView
        //做自己想做的事
        return NO;
    }
    return YES;
}

你可能感兴趣的:(UITapGestureRecognizer与didSelectRowAtIndexPath冲突解决)