roplacebo
roplacebo

Reputation: 2947

Accessibility: How to always set the focus on the navigation item's title view

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.

Upvotes: 8

Views: 12299

Answers (1)

roplacebo
roplacebo

Reputation: 2947

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);
}

Upvotes: 8

Related Questions