MarqueIV MarqueIV - 1 month ago 6
iOS Question

How can you make a UIView subclass which doesn't inherit from UIButton respond to the VoiceOver activation gesture?

We have a custom UIView subclass that for reasons outside of the scope of this discussion cannot simply be converted to a UIButton subclass, but we still want it to respond to accessibility actions as if it were a button.

We know we can set the 'Button' trait and VoiceOver will announce it as such, but how do you actually make it respond to the user 'activating' the control by double-tapping the screen when it has the VoiceOver cursor on it?


Have your tried adding a UITapGestureRecognizer to the Labels?

Something like :

let tapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "tapResponse:")
    tapGesture.numberOfTapsRequired = 1
    sampleLabel.userInteractionEnabled =  true

func tapResponse(recognizer: UITapGestureRecognizer) {