7

I'm using a UINavigationController in my app. When using VoiceOver the backButton has the focus, when a new ViewController is pushed.

I'd rather have the accessibilityLabel of the titleView been focused if the view appears, so that its accessibilityLabel is read first.

Using UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.navigationItem);the titleView seems to be focused, when I create and push the view controller for the first time. But when I come back from another view controller (pushed onto the first one), the focus is on the back button again.

David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
roplacebo
  • 2,837
  • 2
  • 17
  • 19
  • This is generally how VoiceOver works for navigation controllers. Your users are going to expect this behaviour, are you sure you want to change it? – David Rönnqvist Apr 09 '13 at 14:20
  • I'd probably expect to learn about the content the current screen is actually offering, maybe the navigational "back" is not the most important thing at the beginning? – roplacebo Apr 09 '13 at 14:40
  • Where do you call `UIAccessibilityPostNotification` from? Try calling it from `viewDidAppear:`. – rmaddy Apr 09 '13 at 15:50

1 Answers1

6

I should've set the the accessibilityLabel of the titleView, not the navigationItem. The following works:

- (void) viewDidLoad
{
   ...
   self.navigationItem.titleView.accessibilityLabel = @"[text-to-speak]";
}
- (void) viewDidAppear
{
  [super viewDidAppear];       
  UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, self.navigationItem.titleView);
}
Joseph Lord
  • 6,446
  • 1
  • 28
  • 32
roplacebo
  • 2,837
  • 2
  • 17
  • 19
  • 2
    does this work when you a returning from a modal view? I can't get it to NOT go to the back button. Works fine the first time the screen is displayed, but any subsequent "appears" always go to the back button. – Mike M Apr 14 '14 at 21:08