I have a problem after upgrading to Xcode 12 and iOS 14.
Scenario: I have a Nested UITableView: nestedTableView. Like below
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
}
}
}
Then I add another UITableView to nestedTableView's allowGestureEventPassViews array. so I can control which tableView can be scroll.
self.nestedTableView.allowGestureEventPassViews.append(controller.tableView)
In Xcode 11.7, iOS 14 worked just fine.
Log:
tableView 💙 : GAllowGestureEventPassTableView
tableView 💙 : GAllowGestureEventPassTableView
tableView 💙 : GAllowGestureEventPassTableView
tableView 💙 : UITableView
allowGestureEventPassViews contains 💙 : UITableView
gesture pass 💙
but after upgrading to Xcode 12 gesture seen to be different. In Xcode 12 The gesture never pass through the nestedTableView.
tableView 💙 : GAllowGestureEventPassTableView
tableView 💙 : GAllowGestureEventPassTableView
tableView 💙 : GAllowGestureEventPassTableView
tableView 💙 : UITableViewCellContentView
Does anyone has the same problem? or an I misunderstand something about iOS14 gesture.
A pan gesture occurs any time a person moves one or more fingers around the screen. A screen-edge pan gesture is a specialized pan gesture that originates from the edge of the screen. Use the UIPanGestureRecognizer class for pan gestures and the UIScreenEdgePanGestureRecognizer class for screen-edge pan gestures.
There are seven type of gesture that support in ios .
Adding a Tap Gesture Recognizer in Interface Builder You don't need to switch between the code editor and Interface Builder. Open Main. storyboard and drag a tap gesture recognizer from the Object Library and drop it onto the view we added earlier. The tap gesture recognizer appears in the Document Outline on the left.
I found the answer.
In iOS14 some reason, UITableViewCellContentView hierarchy is different.
In tableView(_:cellForRowAt:) I add subview
cell.addSubview(contentScollView)
UITableViewCellContentView is blocking the gesture.
Change to
cell.contentView.addSubview(contentScollView)
This solve my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With