美文网首页
自定义cell中的手势和tableviewcell的点击事件互相

自定义cell中的手势和tableviewcell的点击事件互相

作者: summerTa | 来源:发表于2018-08-23 11:02 被阅读0次

UITapGestureRecognizer *centerTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(centerTapClick)];

    centerTap.delegate=self;

    [_containerView addGestureRecognizer:centerTap];

}

-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch*)touch {

    NSLog(@"输出touch.viewclass:%@",([touch.view class]));

    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {

        returnYES;

    }

    return NO;

}

可以在自定义cell中直接执行这个方法。然后也不会和tableviewcell的点击事件互相冲突

相关文章

网友评论

      本文标题:自定义cell中的手势和tableviewcell的点击事件互相

      本文链接:https://www.haomeiwen.com/subject/qhhpiftx.html