Initial VoiceOver selection

2019-06-15 01:15发布

问题:

I'm adding VoiceOver support to my app. So far, so good, but I'd really like to be able to specify which element is the first one spoken after a UIAccessibilityScreenChangedNotification. I haven't seen a way to do this. Making something the summary element doesn't really seem to do it. Am I missing something?

回答1:

THis has always been perfectly possible to do.

Just write something along the lines of:

- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];

    UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification,
                                self.myFirstElement);
}
@end

This works for both the UIAccessibilityScreenChangedNotification and the UIAccessibilityLayoutChangedNotification. More info: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIAccessibility_Protocol/Introduction/Introduction.html#//apple_ref/c/data/UIAccessibilityLayoutChangedNotification And here: http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/Accessibility/AccessibilityfromtheViewControllersPerspective.html#//apple_ref/doc/uid/TP40007457-CH2-SW1



回答2:

I don't think there is an API value that specifies an order of reading, other than using Summary Element value on startup - it is by design.

So you would have to test the order and default for the UIKit elements or any custom controls, because it depends on your design. You can also mark items as non-accessible elements so they won't be 'read', accessible elements read by default, and containers for accessible elements to allow you to better control your intended interactions. I don't know if making the item selected will help.

I take it you are already using the Accessibility Inspector to test your application before testing on iOS.

If you are needing some background on the subject, Rune's Working With VoiceOver Support and Gemmell's Accessibility for Apps may be worth reading.



回答3:

What about using UIAccessibilityAnnouncementNotification?



回答4:

This technique worked for me.

VoiceOver will announce the value of the first element in the accessibleElements array. This can be sorted to suit your needs.