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.")
}
}