2

I would like to ask how to design voice over assistance on demand with VoiceOver enabled.

I have such code to create UIButton:

_myLocationButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[_myLocationButton setImage:[UIImage imageNamed:@"my_location_icon"] forState:UIControlStateNormal];
_myLocationButton.accessibilityLabel = @"My location";
_myLocationButton.accessibilityHint = @"Double tap to hear where You are, in which zone or near zone and floor information in building";
[_myLocationButton addTarget:self
                      action:@selector(myLocationButtonPressed)
            forControlEvents:UIControlEventTouchUpInside];

Now in myLocationButtonPressed method I have such code:

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, positionDescription);

My question is. When I'm trying to double tap when myLocationButton is active the VoiceOver is saying only: "My location". What I would like is after double tapping I'd like to hear positionDescription not button accessibilityLabel. I know that method myLocationButtonPressed is invoking but from unknown reason posting UIAccessibilityAnnouncementNotification event do nothing and I can't hear anything.

Can somebody give me some advice how to approach this kind of problem.

Marcin Kapusta
  • 5,076
  • 3
  • 38
  • 55

1 Answers1

1

The only way I've found to get announcements to read out consistently, is to post the notification with a delay. This function should help.

- (void)postVoiceOverAnnouncement:(NSString*)message withDelay:(int)seconds {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(seconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"This will get read out");
    });
}

Even with adding the starts media session trait, something is still interrupting the announcement. What you have to watch out for, is the length of your delay. If someone continues to swipe through your app, they could interrupt the announcement. Though, since in a properly accessible application, this information should be available elsewhere, they should be able to find it again. This is of course just a helpful announcement, so as not to shift focus around on unsuspecting VoiceOver users :).

Another problem with your code I noticed:

_myLocationButton.accessibilityHint = @"Double tap to hear where You are, in which zone or near zone and floor information in building";

First off, bravo for including such detailed hints! However, you should not include the "Double tap to...." portion. Users know how to interact with buttons through VoiceOver. Is this the only way to interact with this? Or might one also hit enter on an external keyboard? What about some other hypothetical AT in which the selection gesture is some other interaction... How useful is this hint for someone using a Braille Board??? Just inform the users of the consequence of interacting with the object, let the AT take care of the rest.

MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • Hi. Thanku U very much for Your answer. I found a solution. I set the accessibilityValue on UIButton and the value is my positionDescription. It works ok. When user double tap the button the value is calculated and set. When accessibilityElementDidBecomeFocused or accessibilityElementDidLoseFocus callbacks are called on UIButton instance then I set accessibilityValue to nil. It works but I think Your solution will work too with delay. I think the part "Double tap to" is ok because iOS instructs the user with the same way. – Marcin Kapusta Sep 03 '15 at 11:54
  • Ios does not instruct the user in the same way. When voiceover instructs a user like that, Voiceover is calculating that announcement based on the trait, control type, etc. Key word here is that it is voiceover adding this information and not your app! To voiceover, this the way that this interaction should take place, but to some other AT it is not. If that information is coming from your app, you do not leave room for other ATs to have other instructions. – MobA11y Sep 03 '15 at 12:05
  • What if in a future version of voiceover the selection gesture is a swipe instead of double tap? Is your hint still helpful? – MobA11y Sep 03 '15 at 12:13
  • Can You explain me how to configure UIButton traits so the iOS VoiceOver will say automatically "Double tap to" so I will set hint without "Double tap to" prefix? – Marcin Kapusta Sep 03 '15 at 13:55
  • You should mark your object with the trait of a Button. VoiceOver will then announce the word "button" in it's announcement. Explaining to them every time "double tap to click" would be like me telling you how to use your mouse to click on a button, EVERY TIME YOU SAW ONE. If you had to look for that explanation every time would it not slow you down significantly? They need no further instruction than knowing that the object is a "button", and providing any further instruction goes against Apple's accessibility guidelines, as well as WCag 2.0 requirement 4.1.2. – MobA11y Sep 03 '15 at 17:10