简体   繁体   中英

`UIPanGestureRecognizer` not accessible to users who are using VoiceOver in iOS

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

}

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.

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