Royston Yinkore
Royston Yinkore

Reputation: 591

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?

Upvotes: 5

Views: 3931

Answers (2)

Nirmal Kumar Patel
Nirmal Kumar Patel

Reputation: 11

Set the accessibilityValue to nil or a blank string and the accessibilityLabel to @"£24 per month".

Upvotes: 1

Moxy
Moxy

Reputation: 4212

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)

Upvotes: 5

Related Questions