when VoiceOver is on, is there a way an app can detect a single-finger (left-right)swipe?

前端 未结 2 1930
不知归路
不知归路 2021-01-22 23:32

When VoiceOver is active on an iOS device, the single-finger swipe(left or right) gesture allows users to browse the different elements in the view. Is there a way to detect if

2条回答
  •  爱一瞬间的悲伤
    2021-01-23 00:15

    I ended up creating a category/extension on UIView and overriding accessibilityElementDidBecomeFocused().

    Here I can get a global hook, which gets called every time the accessibility state has changed.

    Swift example:

    extension UIView {
    
    //MARK: Accessibility
    
        override public func accessibilityElementDidBecomeFocused() {
            super.accessibilityElementDidBecomeFocused()
    
            UIApplication.sharedApplication().sendEvent(UIEvent())
        }
    }
    

提交回复
热议问题