在 iOS 中使用 VoiceOver 的用户无法访问 `UIPanGestureRecognizer`
`UIPanGestureRecognizer` not accessible to users who are using VoiceOver in iOS
下面的代码将 UIPanGestureRecognizer
添加到屏幕上的整个视图。当用户用一根手指在屏幕上平移时,会识别 panning/swiping 动作并触发 recognizePanGesture(sender: UIPanGestureRecognizer)
。
不幸的是,我的 UIPanGestureRecognizer
代码目前不符合可访问性。
问题:
如何更改下面的代码以确保在 iOS 中使用 VoiceOver 的用户可以完全访问它?
在启用 VoiceOver 的情况下平移时,用户通常使用的特殊手势是什么?
代码:
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 用户可以通过在其前面加上 "pass-through" 手势来执行平移(在继续手势之前用单指双击并按住)。您可能希望提供一种替代方法来访问该控件。一种方法可能是添加并符合 UIAccessibilityTraitAdjustable
特征。
下面的代码将 UIPanGestureRecognizer
添加到屏幕上的整个视图。当用户用一根手指在屏幕上平移时,会识别 panning/swiping 动作并触发 recognizePanGesture(sender: UIPanGestureRecognizer)
。
不幸的是,我的 UIPanGestureRecognizer
代码目前不符合可访问性。
问题:
如何更改下面的代码以确保在 iOS 中使用 VoiceOver 的用户可以完全访问它?
在启用 VoiceOver 的情况下平移时,用户通常使用的特殊手势是什么?
代码:
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 用户可以通过在其前面加上 "pass-through" 手势来执行平移(在继续手势之前用单指双击并按住)。您可能希望提供一种替代方法来访问该控件。一种方法可能是添加并符合 UIAccessibilityTraitAdjustable
特征。