I am in the process of enabling Catalyst support for a freelancing project — one of the things that I noticed right away is the differing behaviour of scrolling views on MacOS vs iOS. I expected to be able to click and drag UIScrollView
s or UITableView
s as I would normally in the iOS Simulator, but I am only able to scroll these views using the mouse’s scroll wheel (or two finger gesture on a trackpad).
Is there any way I can mimic the UIPanGestureRecognizer
behaviour on iOS for a UIScrollView
or UITableView
using a Click + Drag gesture on MacOS?
Thank you 🙂
4
Answers
I noted the same for UICollectionViews. I decided to use scroll buttons and have them set the selection, and offsets. You can do the same with UIGestureRecognizers in each cell and then set the offsets, etc of the parent UITableView or UICollectionView. I’ve not thought about simple UIScrollViews.
The following will do the trick:
First a convenience extension:
Add a pan gesture to the scroll view:
And finally the selector:
(Full set of CGPoint convenience methods included here: https://github.com/aepryus/Acheron)
If Private API is acceptable, there is a new one in Mac Catalyst 14.0 does exactly this:
It’s worth noting that, as of Monterey, if you use two finger gesture on trackpad, then, it does work exactly as if scrolling on a device – including the bounce.