According to How to add a vertical swipe gesture to iPhone app for all screens, I add a two finger swipe down gesture to window, which works fine on normal pages through the whole app. But it failed on the page has UIScrollView (like UITableViewController). When I swipe down with two fingers on UIScrollView, it just scrolls it as normal. If I swipe from UINavigationBar that above UIScrollView, it works fine again.
The ideal result is that I can scroll tableview by one finger normally, and call some method with swiping page with two fingers without scrolling tableview. This is used in TweetBot to switch dark mode, works perfectly.
According to Apple's document: Using Responders and the Responder Chain to Handle Events, I think I understand how the Responder Chain works, so I want to ask UIScrollView to ignore the two fingers swipe gesture so that it can pass this event to UIWindow. But I can't figure out how to:
I tried to implement UIGestureRecognizerDelegate's func gestureRecognizer(_:, shouldRequireFailureOf otherGestureRecognizer:), or override gestureRecognizerShouldBegin(_) by inherit UITableView. But all didn't work.
Any solutions or advice is welcomed.
from Add vertical two finger swipe gesture to UIScrollView
No comments:
Post a Comment