升级到 Xcode 12 和 iOS 14 后出现问题。
场景:我有一个嵌套的 UITableView:nestedTableView。像下面
class GAllowGestureEventPassTableView: UITableView, UIGestureRecognizerDelegate {
var allowGestureEventPassViews: [UIView] = []
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
panGestureRecognizer.cancelsTouchesInView = false
guard let otherView = otherGestureRecognizer.view else { return false }
print("tableView : \(type(of: otherView))")
if allowGestureEventPassViews.contains(otherView) {
print("allowGestureEventPassViews contains : \(type(of: otherView))")
print("gesture pass ")
return true
} else {
return false
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后我将另一个 UITableView 添加到nestedTableView的 allowGestureEventPassViews 数组中。所以我可以控制哪个 tableView 可以滚动。
self.nestedTableView.allowGestureEventPassViews.append(controller.tableView)
Run Code Online (Sandbox Code Playgroud)
在 …