Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 884
roplacebo Avatar asked Apr 09 '13 14:04

roplacebo


1 Answers

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);
}
like image 176
roplacebo Avatar answered Sep 20 '22 16:09

roplacebo