I have a standard UIViewController
and register a UISwipeGestureRecognizer
, delegate the view to it in my viewDidLoad
override.
The gesture registers and call the appropriate action correctly, however this does not happen when voice over is on.
Is UIGestureRecognizer
only available for standard usage in iOS? Is there a way to get voice over to register these gestures, whether double taps, swipes, pinch/zoom etc?
Figured out how this works, and I think it's worth sharing this:
After looking around at UIView classes, as well as UIAccessibilityTraits, all UIViews and their subclasses have a bitmask using various UIAccessibilityTraits which can be used to: -Designate the standard behavior of the UIView or any class adopting the UIAccessibility protocol. -Allow various configurations such as refresh speed, enabling slider type behavior etc.
Here is a link to all the available traits: https://developer.apple.com/reference/uikit/uiaccessibility/accessibility_traits
For my specific case, I used UIAccessibilityTraitAllowsDirectInteraction and UIAccessibilityTraitUpdatesFrequently. All UIGestureRecognizers then are properly registered, whether swipe, taps, pinch, etc.
They need to be specified as a bitmask, so if you need an element to have these properties, type in:
myView.UIAccessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction | UIAccessibilityTraitUpdatesFrequently
Compiled, ran the app and I got the view telling me what it is, and swiping registers properly without that "bonk" sound you get when something is wrong.
Hope this helps those who also wondered how to get it to work, however this might also conflict slightly with custom views depending on how you want either sighted or visually impaired users to experience the UI. However, I find this way more elegant than creating a whole set of UIElements just to accomodate voice over usage as the interactive method stays the same, and there's no need to write code to hint or explain what to do.
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