Table 查看选择和平移手势

Table View selection and pan gesture

我有一个 table 视图,上面有一个平移手势。当我开始上下平移 table 视图时,tableView selection 被禁用,我无法 select table 查看单元格。

UIPanGesture* tablePanGesture =[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(gestureHandler:)];
tablePanGesture.delegate = self;
[tableView addGestureRecognizer:tablePanGesture];
[tablePanGesture setCancelsTouchesInView:NO];

并且我使用以下委托让我的手势和 table视图手势协同工作:

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{

    return YES;
}

我已经实现了 table 查看 didSelectRowAtIndexPath 的方法,但是当我使用平移时它没有被调用。 pan手势和tableview Delegate有冲突吗?

您错过了这一行:-

[tablePanGesture setCancelsTouchesInView:NO];

这将使 UIPanGesture 识别平移手势并将触摸传递给下一个响应者意味着您的 table 查看 select 或点击。