21

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?

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
David Dunham
  • 8,139
  • 3
  • 28
  • 41
  • 1
    I think at the time (over 10 years ago!), UIAccessibilityScreenChangedNotification was not fully documented. I see that I am now using it. – David Dunham Jan 24 '23 at 17:11

3 Answers3

25

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 UIAccessibilityScreenChangedNotification and UIAccessibilityLayoutChangedNotification.

Now for Swift 5

override func viewDidAppear(_ animated: Bool) {
    UIAccessibility.post(notification: UIAccessibility.Notification.screenChanged,
                         argument: myFirstElement)
}
Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
Jeroen Leenarts
  • 502
  • 4
  • 11
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.

  • I've actually not used Accessibility Inspector, but my game is currently being played by blind users, so this is really only about changing the focus. The problem is that tapping a button shows a new UI element, but it happens to be physically above what you tapped, and that's really a pain to swipe to. – David Dunham Oct 11 '11 at 18:53
0

What about using UIAccessibilityAnnouncementNotification?

Timm
  • 513
  • 3
  • 7
  • That sounds like it would be the way to handle say transient Game Center notifications: “Use this notification to provide accessibility information about events that do not update the application user interface (UI), or that update the UI only briefly.” I want to focus on a specific UI element. – David Dunham Sep 22 '11 at 20:32
  • Hmm, I'm beginning to think I may have to do that, although it is really not the correct answer. (In some cases, the next swipe would be to the focused element, so you will hear it AGAIN.) – David Dunham Oct 11 '11 at 18:58
  • Another downside to using the announcement notification when a view first appears is that its readout is often cut off by the initial VoiceOver selection. – MusiGenesis Apr 02 '13 at 14:37