Royston Yinkore Royston Yinkore - 1 year ago 91
iOS Question

Override VoiceOver message in UITextField - iOS Accessibilty

I have a UITextField that contains "£24 pm" but I want voiceover to say "£24 per month". By setting:

[textView setAccessibilityLabel:@"£24 per month"];

VoiceOver reads out "£24 per month £24 pm".

How do I stop the message in the UITextField from being read out?

Answer Source

You should set the accessibility label to describe the text field (as if it was a key) and the accessibility value for its value.

textField.accessibilityLabel = NSLocalizedString(@"Price", nil);
// textField.accessibilityValue = @"£24 per month";
textField.accessibilityValue = [self transformedPrice:textField.text];

-transformedPrice: should do whatever operation to transform the actual text in your textField to what should be used in voice over. (Don't forget localization)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download