Reputation: 719
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
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
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