小编Dja*_*ree的帖子

Xcode 12 和 iOS 14 中的手势问题

升级到 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)

在 …

gesture swift ios14 xcode12

13
推荐指数
1
解决办法
2386
查看次数

标签 统计

gesture ×1

ios14 ×1

swift ×1

xcode12 ×1