hugocarlmartin
hugocarlmartin

Reputation: 719

iOS 7 UIBarButtonItem with accessibility

Im trying to give my barbuttonitem in the navigationBar a value that the VoiceOver can read, instead of reading the imgname.

I tried this, but it doesn't work:

self.barBtnAbout.accessibilityLabel = NSLocalizedString(@"about", nil);
self.barBtnAbout.accessibilityHint = NSLocalizedString(@"about", nil);

Any bright ideas?

Kind Regards!

Upvotes: 2

Views: 1316

Answers (2)

John Jacecko
John Jacecko

Reputation: 1870

The correct way to setup basic accessibility for a UIBarButtonItem is like this:

myBarButtonItem.isAccessibilityElement = YES;
myBarButtonItem.accessibilityLabel = NSLocalizedString(@"a short description",@"")];
myBarButtonItem.accessibilityTraits = UIAccessibilityTraitButton;

Upvotes: 2

Fredrik Örtman
Fredrik Örtman

Reputation: 86

I have done this using the following:

UIView *view = (UIView*)self.navigationItem.leftBarButtonItem;
[view setIsAccessibilityElement:YES];
[view setAccessibilityLabel:NSLocalizedString(@"about", @"")];
[view setAccessibilityHint:NSLocalizedString(@"about", @"")];

Upvotes: 3

Related Questions