简体   繁体   中英

How to get trackpad / mouse wheel scrolling events in MacOS Catalyst app?

We built our iPad app for MacOS using Catalyst and I cannot figure out how to get two-finger trackpad scrolling gestures to work in a custom UIView. The standard UIKit components (eg, UITableView) scroll with the standard two-finger trackpad scrolling gestures. But how do you handle them in a custom UIView?

The custom UIViewViewController adds a typical UIPanGestureRecognizer which invokes the gesture handler method when the trackpad is pressed and I move my finger. But it doesn't invoke the handler with just two fingers brushing the trackpad.

You can do this now in iOS 13.4 using this code:

panGesture.allowedScrollTypesMask = UIScrollTypeMask.continuous

https://developer.apple.com/documentation/uikit/uipangesturerecognizer/3538978-allowedscrolltypesmask

Confirmed by Apple DTS that this is not currently possible.

We have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations.

(Feb 2020)

If you can put your UIView into a UIScrollView , you can then use the UIScrollViewDelegate methods to detect scrolling. However, you will then need to immediately undo any scrolling movements in scrollViewDidScroll if you don't actually want the view to move.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM