UITableView tapgesture行为

时间:2016-12-13 08:33:08

标签: swift uitableview uigesturerecognizer

当我点按表格视图时,它会触发touchesBegantouchesShouldBegin。但是,我的查看单元格中也有UIPanGestureRecognizer,在平移单元格时,点击其他单元格不会触发touchesShouldBegin

我需要touchesShouldBegin的原因是因为我想在播放单元格时停止触摸。我可以使用其他方法来做到这一点吗?我已尝试将allowsMultipleSelection设置为falsetrue

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    print("This will always be printed")
}

override func touchesShouldBegin(_ touches: Set<UITouch>, with event: UIEvent?, in view: UIView) -> Bool {
    print("This will only be printed when no cells are being panned")

    return true
}

1 个答案:

答案 0 :(得分:0)

尝试将UITableView的{​​{1}}媒体资源设为delaysContentTouches

您还可以尝试将true添加到UIGestureRecognizerDelegate并拥有:

UIPanGestureRecognizer