How to use tap gesture in Accessibility in swift?

后端 未结 3 1192
一个人的身影
一个人的身影 2021-01-20 14:12

I\'m working on app for blind people first i needed to use swipe gesture and after search i can do it by using

 override func accessibilityScroll( direction         


        
相关标签:
3条回答
  • 2021-01-20 14:27

    You shouldn't use tap gesture for UIAccessibility ot try to add tap gestures to UIAccessibility.UIAccessibility is meant for the UIElements where the people can see/hear what is on the screen. You cannot add UIAccessiility for tap gesture functions. What you can do is to post a accessibility notification to the user saying tap to perform something. Again, you need to use buttons to perform an action in UIAccessibility.

    0 讨论(0)
  • 2021-01-20 14:32

    Add this to your code

    overrride func viewDidLoad()
    {
    super.viewDiDLoad()
    let tap = UITapGestureRecognizer(target: self, action: "performTap")
    self.view.addGestureRecognizer(tap)
    }
    

    And to perform the necessary action, add your required code here

    func performTap()
    {
       // Perform you action here
    }
    
    0 讨论(0)
  • 2021-01-20 14:34

    You can override accessibilityScroll method:

    override func accessibilityScroll(_ direction: 
        UIAccessibilityScrollDirection) -> Bool {
    
        super.accessibilityScroll(direction)
    
        if direction == UIAccessibilityScrollDirection.left {
        // do your stuff            
        }
    
        if direction == UIAccessibilityScrollDirection.right {
        // do your stuff        
        }
        return true
    }
    
    0 讨论(0)
提交回复
热议问题