Reputation: 3011
The below code adds a UIPanGestureRecognizer
to the whole view on screen. When a user pans across the screen with one finger the panning/swiping action is recognised and recognizePanGesture(sender: UIPanGestureRecognizer)
is triggered.
Unfortunately though my UIPanGestureRecognizer
code is currently not accessibility compliant.
Questions:
How can I change the code below to ensure that it is completely accessible to users who are using VoiceOver in iOS?
What is the special gesture action a user typically uses when panning with VoiceOver active?
Code:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
panGestureAdd()
}
func panGestureAdd() {
let panGesture: UIPanGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(ViewController.recognizePanGesture(_:)))
panGesture.minimumNumberOfTouches = 1
panGesture.maximumNumberOfTouches = 1
self.view.addGestureRecognizer(panGesture)
}
func recognizePanGesture(sender: UIPanGestureRecognizer) {
print("UIPanGestureRecognizer active.")
}
}
Upvotes: 0
Views: 612
Reputation: 20609
VoiceOver users can perform a pan by prefixing it with the "pass-through" gesture (one-finger double-tap and hold before continuing with the gesture). You may want to offer an alternative method to access the control. One approach might be to add and conform to the UIAccessibilityTraitAdjustable
trait.
Upvotes: 2