iOS accessibility - How do you set the accessibility label for the title of a UINavigationBar?

accessibility, ios, objective-c, voiceover

Solution

I couldn't add an accessibility label, but I found a workaround:

I replace the navigationItem's title View with a UILabel that has accessibility set up.

UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.text = @"myTitle";
[titleLabel setAccessibilityLabel:@"myCustomAccessiblityLabel"];
[titleLabel setFont:[UIFont boldSystemFontOfSize:20.0]];
[titleLabel setBackgroundColor:[UIColor clearColor]];
[titleLabel setTextColor:[UIColor whiteColor]];
[titleLabel sizeToFit];
self.navigationItem.titleView = titleLabel;

I'm not sure why setting the accessibility label doesn't work, but the above code works for my needs.

Problem

Apple's voice over mispronounces the title of one of my views, which is inside a UINavigation Controller. In other parts of the app I have added a custom accessibility label to help it pronounce the company name correctly. How can I set the accessibility label of a UINavigationBar?

Original source