首页 > 解决方案 > 防止 UITableViewCells 在平移时突出显示

问题描述

我正在使用包含 ContainerView 的 UIViewController。在 ContainerView 里面我有一个 UITableViewController。我的 UIViewController 中有一个 PanGestureRecognizer,我用它来关闭它。现在我遇到的问题是,当我平移以关闭 UIViewController 时,被触摸的 UITableViewController 内的 TableViewCells 会短暂突出显示。

我在我的表格视图中禁用了滚动,因为我不需要它。

我将此添加到我的平移手势处理程序中.began,但没有任何效果:

myTableView.isUserInteractionEnabled = false

我也试过:

myGestureRecognizer.cancelsTouchesInView = true

但触摸仍然传递给 TableView 并导致单元格突出显示。有什么解决办法吗?

标签: iosswiftuitableviewuipangesturerecognizer

解决方案


我最终使用了这个:

myGestureRecognizer.delaysTouchesBegan = true

它可能不是在所有情况下都有用,但对于我的 TableView 来说,它可以防止亮点发生。


推荐阅读