简体   繁体   English

使用点击手势时无法访问表格视图

[英]Table view not accessible when using tap gesture

I am using a tap gesture on my view which also has a table view as a subview. 我在视图上使用了轻击手势,该视图也有一个表格视图作为子视图。 The table does scroll but when tapped, instead of calling didSelectRowAtIndexPath it calls the selector associated with the tap gesture. 该表会滚动,但在点击时不会调用didSelectRowAtIndexPath ,而是调用与轻击手势关联的选择器。 I can detect the tapped view by getting tap location. 我可以通过获取点击位置来检测点击的视图。 I want to access didSelectRowAtIndexPath when tapped on table instead of the tap gesture selector. 我想在点击表而不是点击手势选择器时访问didSelectRowAtIndexPath How do I achieve this? 我该如何实现?

Implement the tap gesture's UIGestureRecognizerDelegate , and prevent the gesture if touch is in the tableview. 实现轻击手势的UIGestureRecognizerDelegate,如果触摸在表视图中,则阻止该手势。

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    CGPoint p = [gestureRecognizer locationInView:view] ;
    if (CGRectContainsPoint(tableview.frame, p)) {
        return NO ;
    }
    return YES ;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM