Sittha
Sittha

Reputation: 51

Direct Interaction with Voice Over?

My app is content a single tap with 3 types : 1 fingertap, 2 fingerstap and 3 fingerstap and some swipe gestures.

But when Voice Over is Turn-On they cannot detect a tap correctly.

I have tried

if (UIAccessibilityIsVoiceOverRunning()) {

UIView *interactionView = [[UIView alloc]init];

[self.view addSubview:interactionView];

[self.view bringSubviewToFront:interactionView];

[interactionView setAccessibilityTraits:UIAccessibilityTraitAllowsDirectInteraction]; }

But it doesn't work with the tap

Upvotes: 3

Views: 1498

Answers (1)

Xilexio
Xilexio

Reputation: 1238

To be able to process the taps (touchesBegan:withEvent: etc.) with VoiceOver turned on, you need to set two variables of an UIView:

    view.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction;
    view.isAccessibilityElement = YES;

You didn't set the latter. However, please keep in mind that doing that disables some default gestures made over that view. If you don't want that and just need the basic gestures instead of full control over touches, try adding gesture recognizer (addGestureRecognizer:) like UITapGestureRecognizer to the view.

Upvotes: 4

Related Questions